Skip to content

Instantly share code, notes, and snippets.

@ab5tract
Created March 21, 2016 14:08
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 ab5tract/2e0928088ea1f4059767 to your computer and use it in GitHub Desktop.
Save ab5tract/2e0928088ea1f4059767 to your computer and use it in GitHub Desktop.
Bigint speeds
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