Issue #11581 has been updated by Robert Pawlas.

Description updated

----------------------------------------
Bug #11581: profiler extra method calls
https://bugs.ruby-lang.org/issues/11581#change-54417

* Author: Robert Pawlas
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
I was playing today with Ruby profiler and found something strange in my results. Let's take a sample code from docs:

~~~
require 'profile'

def slow_method
  5000.times do
    9999999999999999*999999999
  end
end

def fast_method
  5000.times do
    9999999999999999+999999999
  end
end

slow_method
fast_method
~~~

Results of methods calls should look like:

~~~
0.00     0.19      0.00        1     0.00   100.00  Object#slow_method
0.00     0.19      0.00        1     0.00    90.00  Object#fast_method
~~~

But my results are:

~~~
35.00     0.15      0.07     5001     0.01     0.03  Object#fast_method
10.00     0.19      0.02     5001     0.00     0.03  Object#slow_method
~~~

And it doesn't seem to be proper. Those methods are called once, not 5001 times.
On 1.9.3 everything works fine. And it doesn't look it is a intentional change. But if yes, please enlighten me. 

Thanks

robsdrops



-- 
https://bugs.ruby-lang.org/