Created
April 15, 2017 13:25
-
-
Save timo/a3a405f977840e8336f50234715e9cd4 to your computer and use it in GitHub Desktop.
program from RT #129779 changed to run with n from 2 through 16
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
use v6; | |
my $r = 2_000_000; | |
say "Counting to $r"; | |
my ($start, $setup, $stop); | |
$start = now; | |
{ | |
my ($i, $j); | |
$j = $r; | |
loop ($i = 0; $i < $j; $i++) { } | |
} | |
$stop = now; | |
say "Non-promise iteration: {$stop - $start}"; | |
my @promises; | |
$start = now; | |
@promises.push(start { | |
my ($i, $j); | |
$j = $r; | |
loop ($i = 0; $i < $j; $i++) { } | |
}); | |
$setup = now; | |
await Promise.allof(@promises); | |
$stop = now; | |
say "One iteration: {$stop - $start} (setup: {$setup - $start})"; | |
@promises = (); | |
for 2..16 -> $iters { | |
$start = now; | |
for (1..$iters) { | |
@promises.push(start { | |
my ($i, $j); | |
$j = $r; | |
loop ($i = 0; $i < $j; $i++) { } | |
}); | |
} | |
$setup = now; | |
await Promise.allof(@promises); | |
$stop = now; | |
say "$iters iterations: {$stop - $start} (setup: {$setup - $start})"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment