Created
March 21, 2016 14:08
-
-
Save ab5tract/2e0928088ea1f4059767 to your computer and use it in GitHub Desktop.
Bigint speeds
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; | |
sub bigpackids(int @ids) { | |
my $ret = 0; | |
my $c = 0; | |
while $c++ < +@ids { | |
$ret = $ret +| (1 +< (@ids[$c] - 1)); | |
} | |
return $ret; | |
} | |
my int @a = ((^256).roll + 1) xx 256; | |
say "Starting: " ~ my $instant = now; | |
bigpackids(@a) xx 10_000; | |
say "Ran bigpackids 10,000 times (sequential): {now - $instant}"; | |
$instant = now; | |
await do for ^4 { | |
start { | |
say "started in thread $_"; | |
bigpackids(@a) xx 2_500; | |
say "finished in thread $_"; | |
} | |
} | |
say "Ran bigpackids 10,000 times (parallel): {now - $instant}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment