Thanks Brent! I hadn’t thought of this at all. Now that you’ve pointed this out to me, I feel that your version is the best illustration yet as to why learning 6 is to forget 5. BTW, I haven’t ventured into parallelizing at all, so your comment gave me the reasons I need.

However, I did some testing using your suggestions and experience the opposite of you. Here’s the code:

my $start = now;
say "^yl: " ~ @array.grep(*.starts-with("yl")).elems;
say "Ordinary Grep duration: " ~ now - $start;
$start = now;
say "^yl: " ~ @array.hyper.grep(*.starts-with("yl")).elems;
say "Hyper Grep duration: " ~ now - $start;
$start = now;
say "^yl: " ~ @array.race.grep(*.starts-with("yl")).elems;
say "race Grep duration: " ~ now - $start;

What’s interesting is that the ordinary grep is the fastest in my testing:

Output:
^yl: 1563
Ordinary Grep duration: 1.4747359
^yl: 1563
Hyper Grep duration: 10.06229302
^yl: 1563
race Grep duration: 5.56080517

As I’ve noted quite a few times in these blog posts, my machine is a relatively old MacBook Pro — 2013 version with a two-core i7 processor. Could it be that my machine is not quite up to the task of parallelization, and that attempts to parallelize incurres a speed penalty instead?

    Jo Christian Oterhals

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade