Created
February 28, 2014 04:56
-
-
Save takikawa/9265530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/load | |
;; This performance test tries to construct lots of unrelated types | |
;; to stress hash-consing/interning of types | |
(displayln "The printouts below are designed to trick drdr into graphing them;") | |
(displayln "they aren't times, but memory usage.") | |
(define (print-memory) | |
(for ((i 10)) | |
(collect-garbage)) | |
(let ([n (current-memory-use)]) | |
(printf "cpu time: ~a real time: ~a gc time: ~a\n" n n n))) | |
(require typed-racket/rep/type-rep | |
typed-racket/types/base-abbrev | |
typed-racket/typecheck/typechecker | |
typed-racket/types/tc-result) | |
(print-memory) | |
(for ([i (in-range 50000)]) | |
(define i-sym (string->symbol (number->string i))) | |
(-val i-sym)) | |
(print-memory) | |
(for ([i (in-range 50000)]) | |
(define i-str (number->string i)) | |
(when (even? i) | |
(tc-expr/check #`'#,i-str (ret (-val i-str))))) | |
(print-memory) | |
(for ([i (in-range 50000)]) | |
(tc-expr/check #`'#,i (ret (-val i)))) | |
(print-memory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With a weak hashtable: | |
The printouts below are designed to trick drdr into graphing them; | |
they aren't times, but memory usage. | |
cpu time: 40594272 real time: 40594272 gc time: 40594272 | |
cpu time: 47484744 real time: 47484744 gc time: 47484744 | |
cpu time: 69327008 real time: 69327008 gc time: 69327008 | |
cpu time: 96697656 real time: 96697656 gc time: 96697656 | |
With a strong hashtable: | |
The printouts below are designed to trick drdr into graphing them; | |
they aren't times, but memory usage. | |
cpu time: 40636960 real time: 40636960 gc time: 40636960 | |
cpu time: 48732632 real time: 48732632 gc time: 48732632 | |
cpu time: 69386568 real time: 69386568 gc time: 69386568 | |
cpu time: 94355464 real time: 94355464 gc time: 94355464 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment