Created
August 24, 2017 00:48
-
-
Save samcv/ecacbea31a89e14d5d0b1dd41dfe118e 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
my $*test-count = 0; | |
my @results; | |
my $b1 = { .defined }; | |
my $b2 = { 0 ≤ $_ }; | |
test-it({ | |
my $b = 'a' x 999999 ~ 'b'; | |
$b ~~ /b/ for ^400; | |
}, $b1, 10000); | |
test-it({ | |
my $b = 'a' x 999999 ~ 'b'; | |
use nqp; | |
nqp::index($b, 'b', 0); | |
}, | |
$b2, | |
10 ); | |
sub test-it (&code, &eval, Int:D $times = 1) { | |
my $t1 = now; | |
my $rtrn; | |
for ^$times { | |
$rtrn = &code; | |
} | |
die unless &eval($rtrn); | |
my $tot = now - $t1; | |
@results.push: $tot; | |
say "Test {++$*test-count}: $tot s"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment