ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Coro/eg/bench
(Generate patch)

Comparing cvsroot/Coro/eg/bench (file contents):
Revision 1.11 by root, Fri Nov 24 11:36:57 2006 UTC vs.
Revision 1.15 by root, Mon Dec 4 13:47:56 2006 UTC

6# call with two calls of transfer in a loop. 6# call with two calls of transfer in a loop.
7 7
8use Coro; 8use Coro;
9use Benchmark; 9use Benchmark;
10 10
11sub a() { } 11sub a($) { }
12 12
13$a = bless {}, main::; 13$a = bless {}, main::;
14 14
15sub b { 15sub b {
16 my ($self) = shift; 16 my ($self) = shift;
32*transfer = \&Coro::State::transfer; 32*transfer = \&Coro::State::transfer;
33 33
34sub doit0 { 34sub doit0 {
35 while() { 35 while() {
36 # some unrolling here as well.. 36 # some unrolling here as well..
37 transfer($c0, $main, 0); transfer($c0, $main, 0); 37 transfer($c0, $main); transfer($c0, $main);
38 transfer($c0, $main, 0); transfer($c0, $main, 0); 38 transfer($c0, $main); transfer($c0, $main);
39 transfer($c0, $main, 0); transfer($c0, $main, 0); 39 transfer($c0, $main); transfer($c0, $main);
40 transfer($c0, $main); transfer($c0, $main);
40 } 41 }
41} 42}
42 43
43sub doit1 { 44sub doit1 {
44 while() { 45 while() {
45 # some unrolling here as well.. 46 # some unrolling here as well..
46 transfer($c1, $main, -1); transfer($c1, $main, -1); 47 transfer($c1, $main); transfer($c1, $main);
47 transfer($c1, $main, -1); transfer($c1, $main, -1); 48 transfer($c1, $main); transfer($c1, $main);
48 transfer($c1, $main, -1); transfer($c1, $main, -1); 49 transfer($c1, $main); transfer($c1, $main);
50 transfer($c1, $main); transfer($c1, $main);
49 } 51 }
50} 52}
51 53
52$c0 = new Coro::State sub { 54$c0 = new Coro::State sub {
53 doit0(1,2,3,4,5,6,7,8,9); 55 doit0(1,2,3,4,5,6,7,8,9);
55 57
56$c1 = new Coro::State sub { 58$c1 = new Coro::State sub {
57 doit1(1,2,3,4,5,6,7,8,9); 59 doit1(1,2,3,4,5,6,7,8,9);
58}; 60};
59 61
62$c0->save (0);
63$c1->save (-1);
64
60transfer($main, $c0, 0); 65transfer($main, $c0);
61transfer($main, $c1, -1); 66transfer($main, $c1);
62 67
63timethese 1000000, { 68timethese 1000000, {
64 empty => '&a; &a', 69 function => 'a(5); a(6)',
65 method => '$a->b(5); $a->b(6)', 70 method => '$a->b(5); $a->b(6)',
66 cede => 'cede', 71 cede => 'cede',
67 transfer0=> 'transfer($main, $c0, 0)', 72 transfer0 => 'transfer($main, $c0)',
68 transfer1=> 'transfer($main, $c1, -1)', 73 transfer1 => 'transfer($main, $c1)',
69}; 74};
70 75
76
77

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines