Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Strange behavior with Benchmark

by aitap (Curate)
on Apr 08, 2013 at 20:28 UTC ( [id://1027591]=note: print w/replies, xml ) Need Help??


in reply to Strange behavior with Benchmark

This is because speed computations are done by CPU time, and a program doesn't use any CPU time while sleeping. Moreover, "real" (CPU + "other things") time is computed using time(2) and thus is measured in seconds, not any more precisely.

You can still try to count the real execution time by using timeit and its returned Benchmark object:

use Benchmark; use feature 'say'; say timeit(5, sub { sleep 4 })->real; say timeit(5, sub { sleep 6 })->real;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found