Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Given this example code, where we uncomment one of the commented lines (and yeah, this is a
very slow way to do a Range, but I didn't actually implement ranges yet):
my $i = 0;
my $nums := GLRSeq.from-loop({ ++$i }, { $i < 100000 });
my @b := GLRArrayCircumfix();
# @b = $nums.GLRmap({ next unless .is-prime; $_ });
# @b = $nums.race(:degree(1)).GLRmap({ next unless .is-prime; $_ });
# @b = $nums.race(:degree(2)).GLRmap({ next unless .is-prime; $_ });
# @b = $nums.race(:degree(3)).GLRmap({ next unless .is-prime; $_ });
# @b = $nums.race(:degree(4)).GLRmap({ next unless .is-prime; $_ });
die 'oops' unless @b.elems == 9592;
I get (on my unloaded quad core machine):
* Without .race: 24.6s
* With .race(:degree(1)): 25.7s (don't pay off the overhead, but we see it's not crazy overhead)
* With .race(:degree(2)): 15.7s
* With .race(:degree(3)): 13.0s
* With .race(:degree(4)): 11.9s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment