Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Sirs, I am using Benchmark::Timer::Class package as follows:

use Benchmark::Timer::Class; use Array::Parallel; @y = (h, c, i, o); @u = ('a', 'b', 'c', 'd'); $obj = Array::Parallel->new(\@y, \@u); $th = Benchmark::Timer::Class->new($obj); ($y, $u) = $th->sort('cmp'); for my $n ( (0 .. $#{@{y}} ) ) { print "$u->[$n] is mapped to $y->[$n]\n"; } $th->report();

The output is:

b is mapped to c
a is mapped to h
c is mapped to i
d is mapped to o
1 trial of sort (74us total)


In this output, what is mean by 74us total

Replies are listed 'Best First'.
Re: Benchmark Timer explanations
by mifflin (Curate) on Jun 13, 2005 at 15:04 UTC
    Joost is correct, it does mean micro seconds.
    Here is the timestr sub in Benchmark::Timer that creates the string...
    sub timestr { my $sec = shift; my $retstr; if($sec >= 1_000) { $retstr = commify(int $sec) . 's'; } elsif($sec >= 1) { $retstr = sprintf $sec == int $sec ? '%ds' : '%0.3fs', $sec; } elsif($sec >= 0.001) { my $ms = $sec * 1_000; $retstr = sprintf $ms == int $ms ? '%dms' : '%0.3fms', $ms; } elsif($sec >= 0.000001) { $retstr = sprintf '%dus', $sec * 1_000_000; } else { # I'll have whatever real-time OS she's having $retstr = $sec . 's'; } $retstr; }
Re: Benchmark Timer explanations
by Joost (Canon) on Jun 13, 2005 at 14:57 UTC