Skip to content

Commit

Permalink
added support for line by line profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Aug 27, 2024
1 parent a88fca4 commit 055a9ad
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions M2/Macaulay2/d/profiler.dd
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,21 @@ measure(c:Code):Expr := (
-- so that everytime evalraw recursively calls eval, this one runs.
export evalprof(c:Code):Expr := (
-- stdIO << tostring(codePosition(c)) << " " << tostring(c) << endl;
stackpush(codePosition(c));
stackpop(measure(c)));
when c
is f:functionCode do (
stackpush(codePosition(c));
stackpop(measure(c)))
is v:semiCode do (
i := 0;
w := v.w;
r := nullE;
n := length(w);
while i < n do (
stackpush(codePosition(c));
r = stackpop(measure(w.i));
i = when r is Error do n else i+1);
r)
else evalraw(c));
evalprofpointer = evalprof;

-- briefly enables the profiler and evaluates the code that follows,
Expand Down

0 comments on commit 055a9ad

Please sign in to comment.