profiling question

S

Stefan Kaes

During profiling some code using ruby 1.8.2 and standard profiler, I
have discovered that class method execution time doesn't get attributed
to the class where the method is defined. Instead it gets attributed to
the class of the object issuing the call. This differs from the way
instance methods are attributed. I'd expect that time gets attributed to
the defining class instead.

I wonder whether this is by design and expected behavior, or a bug.

To verify this, you can run the following code through the profiler and
run grep -e 'foo|bar' on the result.


==========================================================================================

class Base
def self.foo
100.times {|n| n-1}
end
def bar
100.times {|n| n/1}
end
end

class A < Base
end

class B < Base
end

class C < Base
def self.foo
100.times {|n| n+1}
end
def bar
100.times {|n| n*1}
end
end

a = A.new
b = B.new
c = C.new

a.class.foo
b.class.foo
c.class.foo

a.bar
b.bar
c.bar
==========================================================================================

-- stefan
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: profiling question"

|During profiling some code using ruby 1.8.2 and standard profiler, I
|have discovered that class method execution time doesn't get attributed
|to the class where the method is defined. Instead it gets attributed to
|the class of the object issuing the call. This differs from the way
|instance methods are attributed. I'd expect that time gets attributed to
|the defining class instead.
|
|I wonder whether this is by design and expected behavior, or a bug.

It's a bug. I have checked in the fix to the CVS repository.
Thank you.

matz.
 
S

Stefan Kaes

Yukihiro said:
Hi,

In message "Re: profiling question"

|During profiling some code using ruby 1.8.2 and standard profiler, I
|have discovered that class method execution time doesn't get attributed
|to the class where the method is defined. Instead it gets attributed to
|the class of the object issuing the call. This differs from the way
|instance methods are attributed. I'd expect that time gets attributed to
|the defining class instead.
|
|I wonder whether this is by design and expected behavior, or a bug.

It's a bug. I have checked in the fix to the CVS repository.
Thank you.

matz.
Wow. That was quick. Thanks very much.

-- stefan kaes

http://railsexpress.de/blog
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top