… | |
… | |
12 | |
12 | |
13 | |
13 | |
14 | sub a { |
14 | sub a { |
15 | $n++; # do something to taint the benchmark results ;) |
15 | $n++; # do something to taint the benchmark results ;) |
16 | } |
16 | } |
|
|
17 | $|=1; |
17 | |
18 | |
18 | $b = new Coro sub { |
19 | $b = async { |
19 | # do a little unrolling... |
20 | # do a little unrolling... |
20 | while() { |
21 | while() { |
21 | yield; yield; yield; yield; yield; |
22 | yield; yield; yield; yield; yield; |
22 | } |
23 | } |
23 | }; |
24 | }; |
… | |
… | |
26 | |
27 | |
27 | $main = $Coro::main; |
28 | $main = $Coro::main; |
28 | |
29 | |
29 | *transfer = \&Coro::State::transfer; |
30 | *transfer = \&Coro::State::transfer; |
30 | |
31 | |
31 | $c = Coro::State::newprocess { |
32 | $c = Coro::State::_newprocess [sub { |
32 | while() { |
33 | while() { |
33 | transfer($c, $main); transfer($c, $main); |
34 | transfer($c, $main); transfer($c, $main); |
34 | transfer($c, $main); transfer($c, $main); |
35 | transfer($c, $main); transfer($c, $main); |
35 | } |
36 | } |
36 | }; |
37 | }]; |
37 | |
38 | |
38 | transfer($main, $c); |
39 | transfer($main, $c); |
39 | |
40 | |
40 | timethese 100000, { |
41 | timethese 100000, { |
41 | method => '$a->a; $a->a; $a->a; $a->a', |
42 | method => '$a->a; $a->a; $a->a; $a->a', |