diff --git a/compiler/main.stanza b/compiler/main.stanza index d544fce5..78671b47 100644 --- a/compiler/main.stanza +++ b/compiler/main.stanza @@ -71,10 +71,11 @@ defn run-with-timing-log (body:() -> ?T, cmd-args:CommandArgs) -> T : ;If -profile-compiler flag is provided, then execute the body ;with support for profiling. defn run-with-profiler (body:() -> ?T, cmd-args:CommandArgs) -> T : - if flag?(cmd-args, "profile-compiler") : - profiling(body, 100, { stack-collapse(_, cmd-args["profile-compiler"]) }) - else : - body() + generate : + if flag?(cmd-args, "profile-compiler") : + stack-collapse(profiling({ yield(body()) }, 100), cmd-args["profile-compiler"]) + else : + body() ;============================================================ ;====================== Verbosity =========================== diff --git a/core/profiler.stanza b/core/profiler.stanza index 6bc43f9b..c6d8cd42 100644 --- a/core/profiler.stanza +++ b/core/profiler.stanza @@ -280,11 +280,10 @@ public defn stop-profiling () -> ProfileResult: collect-profiling(do-stop-sample-profiling()) ;Profiling wrapper to be called with within -public defn profiling (f:() -> ?T, msecs:Int, g:ProfileResult -> ? = { false }) -> T : +public defn profiling (f:() -> ?, msecs:Int) -> ProfileResult : start-profiling(msecs) - val res = f() - g(stop-profiling()) - res + f() + stop-profiling() ;;; convert to flame-graph format using traditional stack-collapse function