Is there a fast parallel “for” loop in Perl 6?
问题 Given some code which does a bit of math/casting for each number from 1 to 500000, we have options: Simple for loop: for ^500000 -> $i { my $result = ($i ** 2).Str; } . In my unscientific benchmark, this takes 2.8 seconds. The most canonical parallel version does each bit of work in a Promise , then waits for the result. await do for ^500000 -> $i { start { my $result = ($i ** 2).Str; } } takes 19 seconds. This is slow! Creating a new promise must have too much overhead to be worthwhile for