Last active
June 11, 2019 16:23
-
-
Save FGasper/293c6fcb87c5e44115a40657f26d767a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use v5.20; | |
use feature qw(signatures); | |
no warnings qw(experimental::signatures); | |
require Dumbbench; # use() causes breakage w/ perlcc. | |
my $bench = Dumbbench->new( | |
target_rel_precision => 0.005, # seek ~0.5% | |
initial_runs => 20, # the higher the more reliable | |
); | |
$bench->add_instances( | |
Dumbbench::Instance::PerlSub->new( | |
name => 'sig', | |
code => sub { has_sig(1, 2) }, | |
), | |
Dumbbench::Instance::PerlSub->new( | |
name => 'unroll', | |
code => sub { no_sig(1, 2) }, | |
), | |
Dumbbench::Instance::PerlSub->new( | |
name => 'stack', | |
code => sub { no_unroll(1, 2) }, | |
), | |
Dumbbench::Instance::PerlSub->new( | |
name => 'sig_add', | |
code => sub { has_sig_add(1, 2) }, | |
), | |
Dumbbench::Instance::PerlSub->new( | |
name => 'unroll_add', | |
code => sub { no_sig_add(1, 2) }, | |
), | |
Dumbbench::Instance::PerlSub->new( | |
name => 'stack_add', | |
code => sub { no_unroll_add(1, 2) }, | |
), | |
); | |
$bench->run(); | |
$bench->report(); | |
sub has_sig_add ($foo, $bar) { | |
$foo + $bar; | |
} | |
sub no_sig_add { | |
my ($foo, $bar) = @_; | |
$foo + $bar; | |
} | |
sub no_unroll_add { | |
$_[0] + $_[1]; | |
} | |
sub has_sig ($foo, $bar) { | |
} | |
sub no_sig { | |
my ($foo, $bar) = @_; | |
} | |
sub no_unroll { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment