Check performance with Benchmark

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

On 1/13/07, chen li [email protected] wrote:

times.
Hi,

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

— Jan S. [email protected] wrote:

Hi,

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

Jan,

Thank you for your cute idea and my script looks
better now.

Li

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