From c3a4416c69454a8533f352ac8a99549ecab9bbd6 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Sat, 29 Sep 2012 10:05:56 -0400 Subject: [PATCH] Rethink profiler integration. Requires the program to manually call the profiler. This dumps the results in a separate file. original commit: c8d3aea6dd4066c40dc6e47454a81b776efbc23c --- collects/typed-racket/base-env/prims.rkt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/collects/typed-racket/base-env/prims.rkt b/collects/typed-racket/base-env/prims.rkt index 1dc141a0..ac3d836d 100644 --- a/collects/typed-racket/base-env/prims.rkt +++ b/collects/typed-racket/base-env/prims.rkt @@ -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))))))]))