check performance with Benchmark

C

chen li

Hi all,

I know I can use this format to check the performance
of my sctipt:

result= Benchmark.measure{##script included here##}

But this code will look ugly if the script spans many
lines.I wonder 1) if there is a better means and 2)
what if I want to check the same script for 10000
times.


Thanks,

Li



____________________________________________________________________________________
Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index
 
J

Jan Svitok

Hi all,

I know I can use this format to check the performance
of my sctipt:

result= Benchmark.measure{##script included here##}

But this code will look ugly if the script spans many
lines.I wonder 1) if there is a better means and 2)
what if I want to check the same script for 10000
times.

Hi,

1. you can put the script in a method/function and call that.
2. use 10000.times { } ;-)
either result = Benchmark.measure { 10000.times { script }}
or result = 1..10000.map { Benchmark.measure { script }}
 
R

Robert Klemme

I know I can use this format to check the performance
of my sctipt:

result= Benchmark.measure{##script included here##}

But this code will look ugly if the script spans many
lines.I wonder 1) if there is a better means and 2)
what if I want to check the same script for 10000
times.

Just look at the various pieces of sample code using benchmark that are
posted here (comp.lang.ruby / ruby-talk).

Kind regards

robert
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top