8

The following example code should accelerate the execution of a Raku program:

for (1..4).race()  {
    say "Doing $_";
    sleep 1;
 }
 say now - INIT now;

I remember, that it worked some time ago, but now I always end up with 4 seconds runtime. Also using .race() or adding parameters doesn't change anything. What does I have to do, to run 2 processes at the same time?

user2944647
  • 201
  • 1
  • 6
  • It might be a regression. Did you try to use commitable to run it in different versions? – jjmerelo May 25 '20 at 08:46
  • 1
    The default batch size is 64. So if you run your program like that, it will never have enough entries to fill a single batch. Having said that, it looks like it is showing the same behaviour with `.race(batch => 1)`. Investigating. – Elizabeth Mattijsen May 25 '20 at 09:11

1 Answers1

7

You should use race with the named argument batch and the statement prefix race.

say race for (1..4).race(batch=>1)  {
    say "Doing $_";
    sleep 1.rand;$_
}
say now - INIT now;
wamba
  • 3,883
  • 15
  • 21
  • 1
    I also used the named arguments for my tests (batch => 1, degree => 2) but this was not enough. The difference comes from the prefix "race" (in front of the "for"). Thanks!! – user2944647 May 25 '20 at 14:16