Skip to content

Instantly share code, notes, and snippets.

@samcv
Created March 28, 2018 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/5c5c9916d42eca70ae87af87a5dfe9cd to your computer and use it in GitHub Desktop.
Save samcv/5c5c9916d42eca70ae87af87a5dfe9cd to your computer and use it in GitHub Desktop.
my $*test-count = 0;
my @results;
my $b1 = { .defined };
my $b2 = { 0 ≤ $_ };
my @blocks = $b1, $b2;
test-it({
my $b = 'a' x 999999 ~ 'b';
$b ~~ /b/ for ^400;
},
#$b1,
1);
test-it({
my $b = 'a' x 999999 ~ 'b';
use nqp;
nqp::index($b, 'b', 0);
},
#$b2,
1);
sub test-it (&code, Int:D $times = 1) {
my $t1 = now;
my Mu $rtrn;
for ^$times {
$rtrn = &code();
}
#die "Got `$rtrn.perl()` back on test {++$*test-count}, which is wrong" unless @blocks[$*test-count]($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