How can you get the call tree with Python profilers?

I just stumbled on this as well, and spent some time learning how to generate a call graph (the normal results of cProfile is not terribly informative). Future reference, here’s another way to generate a beautiful call-tree graphic with cProfile + gprof2dot + graphViz. ——————— Install GraphViz: http://www.graphviz.org/Download_macos.php easy_install gprof2dot Run profile on the code. …

Read more

How to time the different stages of maven execution

This is the quickest possible way: export MAVEN_OPTS=”-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS \ -Dorg.slf4j.simpleLogger.showDateTime=true” mvn test Results in MAVEN_OPTS=”-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Dorg.slf4j.simpleLogger.showDateTime=true” mvn test 17:06:07,330 [INFO] Scanning for projects… 17:06:07,447 [INFO] 17:06:07,447 [INFO] ———————————————————————— 17:06:07,448 [INFO] Building bimble-server 0.0.1-SNAPSHOT 17:06:07,448 [INFO] ———————————————————————— 17:06:07,747 [INFO] 17:06:07,748 [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ bimble-server — If you then add that environment variable to your …

Read more

saving cProfile results to readable external file

Updated. You can get output of profiler using io.StringIO() and save it into file. Here is an example: import cProfile import pstats import io def my_func(): result = [] for i in range(10000): result.append(i) return result pr = cProfile.Profile() pr.enable() my_result = my_func() pr.disable() s = io.StringIO() ps = pstats.Stats(pr, stream=s).sort_stats(‘tottime’) ps.print_stats() with open(‘test.txt’, ‘w+’) …

Read more

How do I profile my Perl programs?

(This is the official perlfaq answer, minus any subsequent edits) The Devel namespace has several modules which you can use to profile your Perl programs. The Devel::DProf module comes with Perl and you can invoke it with the -d switch: $ perl -d:DProf program.pl After running your program under DProf, you’ll get a tmon.out file …

Read more