Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Vice versa. Look at the Rate column — it shows the speed of the function! The more times a second the function is called, the faster it is :) So in this table (produced by the benchmark involving all three variants)
Rate interval HiRes::time buitin time() interval 88470/s -- -53% -95% HiRes::time 188363/s 113% -- -89% buitin time() 1753092/s 1882% 831% --
builtin time() is 9 times faster than Time::HiRes::time, which is nearly 2 times faster than the weird variant with tv_interval!

Benchmark code is here:

#!/usr/bin/perl use Time::HiRes; use Benchmark qw(:all) ; # Use Perl code in strings... cmpthese(-1, { 'interval' => sub { my $t0 = [Time::HiRes::gettimeofday]; my $elapsed = Time::HiRes::tv_interval($t0)} , 'HiRes::time' => sub { my $t0 = Time::HiRes::time(); my $elapsed = Time::HiRes::time() - $t0; }, 'buitin time()' => sub { my $t0 = time; my $elapsed = time - $t0; }, });

     s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print

In reply to Re^3: Measuring time intervals using Time::HiRes -- time vs. gettimeofday and tv_interval by Ieronim
in thread Measuring time intervals using Time::HiRes -- time vs. gettimeofday and tv_interval by hrr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-25 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found