From: "Brian Schröder" Date: 2004-12-01T07:04:22+09:00 Subject: Re: profile On Wed, 1 Dec 2004 06:52:47 +0900 "Joe Van Dyk" wrote: > Hi, > > Still pretty new to Ruby and profiling. Are there any tools I can use to > analyze my Ruby program to see where it's spending the bulk of the CPU time? > > Thanks, > Joe > > ruby -rprofile -e'puts (1..200).inject(0) { | r, i | r + (-1)**i * 1.0 / i }' -0.690653430481824 % cumulative self self total time seconds seconds calls ms/call ms/call name 44.44 0.04 0.04 1 40.00 80.00 Range#each 22.22 0.06 0.02 200 0.10 0.10 Fixnum#** 22.22 0.08 0.02 200 0.10 0.10 Float#/ 0.00 0.08 0.00 1 0.00 0.00 Fixnum#+ 0.00 0.08 0.00 200 0.00 0.00 Fixnum#* 0.00 0.08 0.00 1 0.00 0.00 Kernel.puts 0.00 0.08 0.00 2 0.00 0.00 IO#write 0.00 0.08 0.00 199 0.00 0.00 Float#+ 0.00 0.08 0.00 1 0.00 80.00 Enumerable.inject 0.00 0.08 0.00 1 0.00 90.00 #toplevel 0.00 0.08 0.00 1 0.00 0.00 Profiler__.start_profile 0.00 0.08 0.00 1 0.00 0.00 Float#to_s -- Brian Schr�der http://www.brian-schroeder.de/