File tree Expand file tree Collapse file tree 5 files changed +35
-1
lines changed Expand file tree Collapse file tree 5 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1+ #lang racket/base
2+
3+ (require rackunit)
4+ (require racket/system
5+ racket/port
6+ math/statistics)
7+
8+ (define (get-total-time profiling-command)
9+ (string->number (car (regexp-match #rx"[0-9]+ " (car (regexp-match #rx"/[0-9]+ ms " (with-output-to-string (lambda () (system profiling-command)))))))))
10+
11+ (for ([i (in-range 5 )])
12+ (define whole-time (get-total-time "racket raco.rkt test-inputs/main.rkt " ))
13+ (define instantiation-only-time (get-total-time "racket raco.rkt --instantiation-only test-inputs/main.rkt " ))
14+ (check-true (> whole-time instantiation-only-time)))
Original file line number Diff line number Diff line change 1212(define boundary-view-file #f )
1313(define boundary-view-key-file #f )
1414(define report-space-efficient? #f )
15+ (define instantiation-only? #f )
16+
1517(define file
1618 (command-line #:program (short-program+command-name)
1719 #:once-each
2729 [("--report-space-efficient " )
2830 "Distinguish space-efficient contracts from non "
2931 (set! report-space-efficient? #t )]
32+ [("--instantiation-only " )
33+ "Exclude setup of module imports from measurements "
34+ (set! instantiation-only? #t )]
3035 #:args (filename)
3136 filename))
3237
38+ (define visited-module (and instantiation-only? (module-to-profile file )))
39+
3340(collect-garbage)
3441(collect-garbage)
3542(collect-garbage)
3946 #:boundary-view-file boundary-view-file
4047 #:boundary-view-key-file boundary-view-key-file
4148 #:report-space-efficient? report-space-efficient?
42- (dynamic-require (module-to-profile file ) #f ))
49+ (dynamic-require (or visited- module (module -to-profile file ) ) #f ))
4350
4451(module test racket/base) ; don't run for testing
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ The simplest way to use this tool is to use the @exec{raco contract-profile}
2828command, which takes a file name as argument, and runs the contract profiler on
2929the @racket[main] submodule of that file (if it exists), or on the module
3030itself (if there is no @racket[main] submodule).
31+ If the @exec{--instantiation-only} flag is given, only the instantiation of the
32+ module is profiled, and the profile will not include the module 's initial
33+ visitation
34+ (see @secref["mod-parse " #:doc '(lib "scribblings/reference/syntax-model.scrbl " )]).
3135The tool's output is decribed below.
3236}
3337
Original file line number Diff line number Diff line change 1+ #lang racket
2+ (require "u-module.rkt " )
3+
4+ (define result (u-decrement 2 ))
Original file line number Diff line number Diff line change 1+ #lang racket
2+
3+ (provide u-decrement)
4+
5+ (define (u-decrement x) (- x 1 ))
You can’t perform that action at this time.
0 commit comments