diff --git a/collects/typed-racket/optimizer/tool/profiling.rkt b/collects/typed-racket/optimizer/tool/profiling.rkt index 0e545b13de..a51d32a512 100644 --- a/collects/typed-racket/optimizer/tool/profiling.rkt +++ b/collects/typed-racket/optimizer/tool/profiling.rkt @@ -9,15 +9,15 @@ (define compiled-module-name 'optimization-coach-compiled-module) (define (generate-profile this source) + (define res-mpi (make-resolved-module-path compiled-module-name)) (define snapshots (run-inside-optimization-coach-sandbox this (lambda () - (parameterize ([current-module-declare-name - (make-resolved-module-path compiled-module-name)]) + (parameterize ([current-module-declare-name res-mpi]) (eval (let ([input (open-input-text-editor source)]) (port-count-lines! input) - (read-syntax #f input))) + (read-syntax res-mpi input))) ;; Require, to run the body, without actually adding anything to the ;; current namespace, in case the module calls `eval'. (eval '(require profile/sampler)) @@ -25,6 +25,11 @@ (dynamic-require '',compiled-module-name #f) (sampler 'stop) (sampler 'get-snapshots))))))) - (for ([n (profile-nodes (analyze-samples snapshots))]) + (define (right-file? node) + (define src (node-src node)) + (equal? (and src (srcloc-source src)) res-mpi)) + (define nodes + (filter right-file? (profile-nodes (analyze-samples snapshots)))) + (for ([n nodes]) (printf "~a -- ~a -- ~a -- ~a\n" (node-id n) (node-total n) (node-self n) (node-src n))) - (profile-nodes (analyze-samples snapshots))) + nodes)