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