Rethink profiler integration.

Requires the program to manually call the profiler. This dumps the results in
a separate file.

original commit: c8d3aea6dd4066c40dc6e47454a81b776efbc23c
This commit is contained in:
Vincent St-Amour 2012-09-29 10:05:56 -04:00
parent 4ec778616e
commit c3a4416c69

View File

@ -1194,3 +1194,20 @@ This file defines two sorts of primitives. All of them are provided into any mod
(define-syntax-rule (for*/flvector: e ...)
(base-for/flvector: for*: e ...))
(provide optimization-coach-profile)
(require profile/sampler profile/analyzer profile/render-text)
(require racket/serialize)
(define-syntax (optimization-coach-profile stx)
(syntax-parse stx
[(_ body ...)
(ignore
#`(let ([sampler (create-sampler (current-thread) 0.005)])
body ...
(sampler 'stop)
(define samples (sampler 'get-snapshots))
(render (analyze-samples samples))
(with-output-to-file #,(string-append (path->string (syntax-source stx)) ".profile")
#:exists 'replace
(lambda () (write (serialize samples))))))]))