… | |
… | |
6 | # call with two calls of transfer in a loop. |
6 | # call with two calls of transfer in a loop. |
7 | |
7 | |
8 | use Coro; |
8 | use Coro; |
9 | use Benchmark; |
9 | use Benchmark; |
10 | |
10 | |
11 | sub a() { } |
11 | sub a($) { } |
12 | |
12 | |
13 | $a = bless {}, main::; |
13 | $a = bless {}, main::; |
14 | |
14 | |
15 | sub b { |
15 | sub b { |
16 | my ($self) = shift; |
16 | my ($self) = shift; |
… | |
… | |
19 | } |
19 | } |
20 | |
20 | |
21 | $b = async { |
21 | $b = async { |
22 | # do a little unrolling... |
22 | # do a little unrolling... |
23 | while() { |
23 | while() { |
|
|
24 | cede; cede; cede; cede; cede; |
24 | cede; cede; cede; cede; cede; |
25 | cede; cede; cede; cede; cede; |
25 | } |
26 | } |
26 | }; |
27 | }; |
27 | |
28 | |
28 | cede; |
29 | cede; |
… | |
… | |
35 | while() { |
36 | while() { |
36 | # some unrolling here as well.. |
37 | # some unrolling here as well.. |
37 | transfer($c0, $main); transfer($c0, $main); |
38 | transfer($c0, $main); transfer($c0, $main); |
38 | transfer($c0, $main); transfer($c0, $main); |
39 | transfer($c0, $main); transfer($c0, $main); |
39 | transfer($c0, $main); transfer($c0, $main); |
40 | transfer($c0, $main); transfer($c0, $main); |
|
|
41 | transfer($c0, $main); transfer($c0, $main); |
40 | } |
42 | } |
41 | } |
43 | } |
42 | |
44 | |
43 | sub doit1 { |
45 | sub doit1 { |
44 | while() { |
46 | while() { |
45 | # some unrolling here as well.. |
47 | # some unrolling here as well.. |
46 | transfer($c1, $main); transfer($c1, $main); |
48 | transfer($c1, $main); transfer($c1, $main); |
47 | transfer($c1, $main); transfer($c1, $main); |
49 | transfer($c1, $main); transfer($c1, $main); |
48 | transfer($c1, $main); transfer($c1, $main); |
50 | transfer($c1, $main); transfer($c1, $main); |
|
|
51 | transfer($c1, $main); transfer($c1, $main); |
49 | } |
52 | } |
50 | } |
53 | } |
51 | |
54 | |
52 | $c0 = Coro::State::_newprocess [sub { |
55 | $c0 = new Coro::State sub { |
53 | doit0(1,2,3,4,5,6,7,8,9); |
56 | doit0(1,2,3,4,5,6,7,8,9); |
54 | }]; |
57 | }; |
55 | |
58 | |
56 | $c1 = Coro::State::_newprocess [sub { |
59 | $c1 = new Coro::State sub { |
57 | doit1(1,2,3,4,5,6,7,8,9); |
60 | doit1(1,2,3,4,5,6,7,8,9); |
58 | }]; |
61 | }; |
|
|
62 | |
|
|
63 | #$c0->save (0); |
|
|
64 | #$c1->save (-1); |
59 | |
65 | |
60 | transfer($main, $c0); |
66 | transfer($main, $c0); |
61 | transfer($main, $c1); |
67 | transfer($main, $c1); |
62 | |
68 | |
|
|
69 | #Coro::State::enable_times 1; |
|
|
70 | #use Coro::Debug; Coro::Debug::command "ps";#d# |
|
|
71 | #(async { |
63 | timethese 100000, { |
72 | timethese 5000000, { |
64 | empty => '&a; &a', |
73 | function => 'a(5); a(6)', |
65 | method => '$a->b(5); $a->b(6)', |
74 | method => '$a->b(5); $a->b(6)', |
66 | cede => 'cede', |
75 | cede => 'cede', |
67 | transfer0=> 'transfer($main, $c0, 0)', |
76 | transfer0 => 'transfer($main, $c0)', |
68 | transfer1=> 'transfer($main, $c1)', |
77 | transfer1 => 'transfer($main, $c1)', |
69 | }; |
78 | }; |
|
|
79 | #})->join; |
|
|
80 | #use Coro::Debug; Coro::Debug::command "ps";#d# |
70 | |
81 | |
|
|
82 | |
|
|
83 | |