Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Loop Timing

by BMaximus (Chaplain)
on Feb 27, 2006 at 17:34 UTC ( [id://533086]=note: print w/replies, xml ) Need Help??


in reply to Loop Timing

This is what Benchmark is for. So if you want to time how long it took for that particular itteration of the loop through then you would do something like this.
use POSIX; use Benchmark; for (my $count = 0; $count <= 11; $count++) { my $bench_1 = Benchmark->new(); ... # do some intense stuff here my $bench_2 = Benchmark->new(); my $time_diff = timediff($bench_2, $bench_1); print "This interaction took: " . timestr($time_diff) . " on " . strftime("%a %b %e %H:%M:%S %Y", localtime); }


Update: Woops, flipped $bench_1 and $bench_2 to give the correct timing.

BMaximus

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-25 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found