in reply to Re^2: Measuring time intervals using Time::HiRes -- time vs. gettimeofday and tv_interval
in thread Measuring time intervals using Time::HiRes -- time vs. gettimeofday and tv_interval
builtin time() is 9 times faster than Time::HiRes::time, which is nearly 2 times faster than the weird variant with tv_interval!Rate interval HiRes::time buitin time() interval 88470/s -- -53% -95% HiRes::time 188363/s 113% -- -89% buitin time() 1753092/s 1882% 831% --
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; }, });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Measuring time intervals using Time::HiRes -- time vs. gettimeofday and tv_interval
by Tanktalus (Canon) on Jul 18, 2006 at 20:21 UTC |