Perfomance tuning

E

Emil Sandin

Hi,
I have an application that takes a little to long to execute. I would
like to know where I could gain most.

Whenever a metod is called, I would like to store the execution time and
number of executions. Then, at the end of the applications execution,
print it out. Something like:

Object1 =>
method1 => called 10 times, 30 milliseconds total time
method2 => called 1 times, 5 milliseconds total time
Object2 =>
method1 => called 1 times, 2 milliseconds total time
method2 => called 30 times, 500 milliseconds total time
...

How would I do this?
Regards
Emil
 
A

Alex Young

Emil said:
Hi,
I have an application that takes a little to long to execute. I would
like to know where I could gain most.

Whenever a metod is called, I would like to store the execution time and
number of executions. Then, at the end of the applications execution,
print it out. Something like:

Object1 =>
method1 => called 10 times, 30 milliseconds total time
method2 => called 1 times, 5 milliseconds total time
Object2 =>
method1 => called 1 times, 2 milliseconds total time
method2 => called 30 times, 500 milliseconds total time
...

How would I do this?

Investigate 'profile' in the standard library
(http://www.rubycentral.com/book/trouble.html) or ruby-prof
(http://ruby-prof.rubyforge.org/). Both do what you want, but the
latter is more comprehensive.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top