I am optimizing some code and a profiler would help.
Unfortunately Ruby standard profiler seems not to work for me.
Maybe because my software is multi-threaded. I just can’t get
any output at all.
Try the attached, and tell me what you get.
GPG key ID: BEEA7EFE
Thanks for the attached code. I did not used it directly, instead I
used it a starting point for some profiler I added in the system I am
I enjoyed the simplicity of the scheme where you basically time how long
is spent per file+line using the time diff when control passes to another
This is definitely thread safe too.
Thanks to some code parsing in my system I was able to consolidate the
results at the method level (adding time spent in every line inside that
method). As a result, instead of getting a list of the “top” most CPU
intensive lines of code, I get a list of the “top” method.
The main drawback is that of course only time spent inside de method
itself is available. Not the time spent in the method + any method called
by that method. This is OK for micro-optimization, but the big picture
would require timing of the call flows.
The later would require a different scheme, looking at the call stack,
much like the standard profiler does using set_trace_func() I guess. In
that scheme one must carefully handle thread switches, else results are
useless (for those dealing with threads I mean).
At 02:22 21/06/2002 +0900, you wrote:
On Thursday 20 June 2002 09:32 am, Jean-Hugues ROBERT wrote:
Phone: +33 (0) 4 92 27 74 17