ruby-prof – A fast code profiler for Ruby
ruby-prof just hit Debian unstable:
% apt-cache show ruby-prof | sed -ne "/^Description/,/^$/p" Description: A fast code profiler for Ruby ruby-prof is runs a ruby program and keeps track of the amount of time spent in each method. At the end of execution it displays collected information. Its features include: * Speed - it is a C extension and therefore many times faster than the standard Ruby profiler. * Flat Profiles - similar to the reports generated by the standard Ruby profiler. * Graph profiles - similar to GProf, these show how long a method runs, which methods call it and which methods it calls. * Threads - supports profiling multiple threads simultaneously. * Recursive calls - supports profiling recursive method calls. * Reports - can generate both text and cross-referenced html reports. * Output - can output to standard out or to a file.
Demo:
% ruby-prof /usr/share/doc/ruby1.8-examples/examples/fib.rb 6765 Thread ID: -605742108 %self cumulative total self children calls self/call total/call name 69.70 0.23 0.33 0.23 0.10 21891 0.00 0.00 Object#fib 0.00 0.23 0.00 0.00 0.00 1 0.00 0.00 Module#method_added 0.00 0.23 0.00 0.00 0.00 1 0.00 0.00 Kernel#print 0.00 0.23 0.33 0.00 0.33 1 0.00 0.33 Kernel#load 0.00 0.23 0.00 0.00 0.00 2 0.00 0.00 IO#write 0.00 0.23 0.00 0.00 0.00 1 0.00 0.00 Fixnum#to_s 18.18 0.29 0.06 0.06 0.00 21891 0.00 0.00 Fixnum#< 9.09 0.32 0.03 0.03 0.00 21890 0.00 0.00 Fixnum#- 3.03 0.33 0.01 0.01 0.00 10945 0.00 0.00 Fixnum#+ 0.00 0.33 0.33 0.00 0.33 1 0.00 0.33 #toplevel
November 2nd, 2006 at 20:17
nice, thanks!