Created
August 29, 2016 03:39
-
-
Save kentfredric/0c7a0dbb0c79f062ac07796ae4604ca3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Dumbbench; | |
use Time::HiRes qw( gettimeofday ); | |
my $bench = Dumbbench->new( | |
target_rel_precision => 0.005, # seek ~0.5% | |
initial_runs => 20, # the higher the more reliable | |
); | |
my $iruns = 1e5; | |
$bench->add_instances( | |
Dumbbench::Instance::PerlSub->new( | |
name => "noop", | |
code => sub { | |
for ( 1 .. $iruns ) { | |
my $value = [ $_, $_ ]; | |
defined $value and next; | |
} | |
} | |
), | |
Dumbbench::Instance::PerlSub->new( | |
name => "gettimeofday", | |
code => sub { | |
for ( 1 .. $iruns ) { | |
my $value = [gettimeofday]; | |
defined $value and next; | |
} | |
} | |
) | |
); | |
$bench->run; | |
$bench->report; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
noop: 3.6766e-02 ± 2.1e-05 per 1e5 its | |
gettimeofday 15.1750e-02 ± 28.0e-05 per 1e5 its | |
= 11.4984e-02 per 1e5 its | |
= 11.4984e-07 per it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
noop: Ran 31 iterations (11 outliers). | |
noop: Rounded run time per iteration: 3.6766e-02 +/- 2.1e-05 (0.1%) | |
gettimeofday: Ran 28 iterations (8 outliers). | |
gettimeofday: Rounded run time per iteration: 1.5175e-01 +/- 2.8e-04 (0.2%) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment