[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Perfomance tuning

Emil Sandin

3/13/2007 10:37:00 AM

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

--
Posted via http://www.ruby-....

3 Answers

A. S. Bradbury

3/13/2007 10:47:00 AM

0

On 3/13/07, Emil Sandin <esandin@gmail.com> wrote:
> Hi,
> I have an application that takes a little to long to execute. I would
> like to know where I could gain most.

The best way is ruby-prof (http://ruby-prof.rub...). It will
generate ascii or html formatted output showing the time spent in
methods. See http://www.oreillynet.com/ruby/blog/2006/08/profiling_ruby_code_with_...
for links to a series of 3 blog posts describing its use.

Alex

Alex Young

3/13/2007 10:49:00 AM

0

Emil Sandin wrote:
> 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/tr...) or ruby-prof
(http://ruby-prof.ruby...). Both do what you want, but the
latter is more comprehensive.

--
Alex

Emil Sandin

3/13/2007 10:59:00 AM

0

Thank you for your quick replies, I will look into this at once.

/Emil

--
Posted via http://www.ruby-....