[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

check performance with Benchmark

Li Chen

1/13/2007 4:03:00 AM

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.c...

2 Answers

Jano Svitok

1/13/2007 10:00:00 AM

0

On 1/13/07, chen li <chen_li3@yahoo.com> wrote:
> 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 }}

Robert Klemme

1/13/2007 10:01:00 AM

0

On 13.01.2007 05:03, chen li wrote:
> 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