Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

A few more tips

by gryng (Hermit)
on Jul 25, 2000 at 20:58 UTC ( [id://24303]=note: print w/replies, xml ) Need Help??


in reply to Benchmarking Your Code

Oh I like this tutorial. Here are two more things that can be useful:

First, turnstep talks alot about trying to get the number of iterations to equal about 5 seconds of cpu time. I agree with this value, however benchmark will do this tuning for you! Simply provide -5 as the number of iterations and benchmark will iterate the loop for at least 5 cpu seconds. For your final benchmark you may want to bring that number up to -10 or -20, just to make sure.

Also, differences of less than 5% should probably be ignored -- not because they are not happening, but rather because they may disappear on a different computer setup. And more importantly, you probably don't need to trade a 5% speed up for other considerations, such as code readability.

Here is sample output using a negative value:

Benchmark: running Method One, Method Two, each for at least 10 CPU se +conds... Method One: 11 wallclock secs (10.10 usr + 0.01 sys = 10.11 CPU) @ 28 +1.21/s (n=2843) Method Two: 11 wallclock secs (10.51 usr + 0.02 sys = 10.53 CPU) @ 78 +.82/s (n=830)

Now, note that with this sort of run, you don't want to look at the CPU seconds used, rather you want to look at the last two numbers, the rate and the iteration count. These will tell you which is faster.

Thanks again turnstep seeya,
Gryn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://24303]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-19 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found