J
javachallenge
I am using Windows, and I was testing the profiler with the simple
sieve.rb program.
I may not have a good understanding of Ruby's profiler but It seems
that it gives me wrong percentages... I guess it is due to the overhead
of the profiler while the process is not too much cpu bound. However if
it shows wrong percentages, to me it's still a bug.
So according to the output below, 100% of the time is gone with
Profiler__.start_profile, while 51.61% is gone with Numeric#step. All
this totaling 151.61%!
Am I missing something?
Thanks in advance. I am such a newbie JC
C:\code\ruby>ruby -r profile sieve.rb
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73,
79, 83, 89, 97
% cumulative self self total
time seconds seconds calls ms/call ms/call name
100.00 0.03 0.03 1 31.00 31.00
Profiler__.start_profile
51.61 0.05 0.02 4 4.00 4.00 Numeric#step
0.00 0.05 0.00 1 0.00 0.00 Kernel.Integer
0.00 0.05 0.00 2 0.00 8.00 Range#each
0.00 0.05 0.00 1 0.00 31.00 #toplevel
0.00 0.05 0.00 9 0.00 0.00 Array#[]
0.00 0.05 0.00 2 0.00 0.00 IO#write
0.00 0.05 0.00 26 0.00 0.00
Kernel.respond_to?
0.00 0.05 0.00 8 0.00 0.00 Integer#succ
0.00 0.05 0.00 4 0.00 0.00 Fixnum#*
0.00 0.05 0.00 10 0.00 0.00 Float#<=>
0.00 0.05 0.00 1 0.00 0.00 Kernel.puts
0.00 0.05 0.00 25 0.00 0.00 Fixnum#to_s
0.00 0.05 0.00 10 0.00 0.00 Float#coerce
0.00 0.05 0.00 1 0.00 0.00 Array#shift
0.00 0.05 0.00 1 0.00 0.00 Array#compact
0.00 0.05 0.00 4 0.00 0.00 Fixnum#==
0.00 0.05 0.00 10 0.00 0.00 Fixnum#<=>
0.00 0.05 0.00 1 0.00 0.00 Array#join
0.00 0.05 0.00 1 0.00 0.00 Math.sqrt
0.00 0.05 0.00 203 0.00 0.00 Array#[]=
sieve.rb program.
I may not have a good understanding of Ruby's profiler but It seems
that it gives me wrong percentages... I guess it is due to the overhead
of the profiler while the process is not too much cpu bound. However if
it shows wrong percentages, to me it's still a bug.
So according to the output below, 100% of the time is gone with
Profiler__.start_profile, while 51.61% is gone with Numeric#step. All
this totaling 151.61%!
Am I missing something?
Thanks in advance. I am such a newbie JC
C:\code\ruby>ruby -r profile sieve.rb
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73,
79, 83, 89, 97
% cumulative self self total
time seconds seconds calls ms/call ms/call name
100.00 0.03 0.03 1 31.00 31.00
Profiler__.start_profile
51.61 0.05 0.02 4 4.00 4.00 Numeric#step
0.00 0.05 0.00 1 0.00 0.00 Kernel.Integer
0.00 0.05 0.00 2 0.00 8.00 Range#each
0.00 0.05 0.00 1 0.00 31.00 #toplevel
0.00 0.05 0.00 9 0.00 0.00 Array#[]
0.00 0.05 0.00 2 0.00 0.00 IO#write
0.00 0.05 0.00 26 0.00 0.00
Kernel.respond_to?
0.00 0.05 0.00 8 0.00 0.00 Integer#succ
0.00 0.05 0.00 4 0.00 0.00 Fixnum#*
0.00 0.05 0.00 10 0.00 0.00 Float#<=>
0.00 0.05 0.00 1 0.00 0.00 Kernel.puts
0.00 0.05 0.00 25 0.00 0.00 Fixnum#to_s
0.00 0.05 0.00 10 0.00 0.00 Float#coerce
0.00 0.05 0.00 1 0.00 0.00 Array#shift
0.00 0.05 0.00 1 0.00 0.00 Array#compact
0.00 0.05 0.00 4 0.00 0.00 Fixnum#==
0.00 0.05 0.00 10 0.00 0.00 Fixnum#<=>
0.00 0.05 0.00 1 0.00 0.00 Array#join
0.00 0.05 0.00 1 0.00 0.00 Math.sqrt
0.00 0.05 0.00 203 0.00 0.00 Array#[]=