Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I've always wished I could do some profiling like you get in Wolfram Workbench, but directly from Mathematica, without using or having Workbench. If it is possible, how can I do it?

share|improve this question
Related question. – Leonid Shifrin Jul 1 '12 at 20:10
I love the Please help me! part – belisarius is forth Jul 1 '12 at 20:23
also related… – belisarius is forth Jul 1 '12 at 20:24
A shame the Please help me! has been removed from the original post. – Wizard Jul 9 at 11:14

1 Answer 1

up vote 64 down vote accepted

You can put your Mathematica session in debug mode by going to Evaluation->Debugger

Then, make some definitions and wrap the profiled code in RuntimeTools`Profile

For example, in debug mode, run

f[x_] := x^2

Table[f[x], {100000}]; // RuntimeTools`Profile

and you get a nice

Mathematica graphics

As @acl mentioned in the comments, clicking in the gray area in the output notebook's lines takes you to the related code

share|improve this answer
Any idea, why test[] := Module[{}, Print["Here"]; Pause[0.1]; Print["There"]; Pause[1]; Return[2]] and test[] // RuntimeTools`Profile does not work, even though your example works correctly? – Ajasja Jul 2 '12 at 8:37
Also, do you happen to know what RuntimeTools`ProfileFunction does? – Ajasja Jul 2 '12 at 10:15
@Ajasja, sorry about the name ;). I am not sure. It don't think this profiler is without quirks. For starters, I think it doesn't account for Pauses, and without those pauses your code is too fast – Rojo Jul 2 '12 at 19:55
Unfortunately this solution does not seem to work for more complicated constructs, like funcitons called within Module, etc.. – Wizard Oct 17 '14 at 11:40
My issues mentioned in the comment above seem to be resolved in Mathematica 10.1. I also think that Mr.Wizard's suggestion should work in older versions, but I am not sure if I recall that correctly. Sorry for the late reply. – Wizard Jul 9 at 11:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.