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
-
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.
|