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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.