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

Comparing Coro/eg/bench (file contents):
Revision 1.9 by root, Sat Aug 11 19:59:19 2001 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 = Coro::State::_newprocess [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);
54}];
55
56$c1 = Coro::State::_newprocess [sub {
57 doit1(1,2,3,4,5,6,7,8,9);
58}];
59
60transfer($main, $c0, 0);
61transfer($main, $c1, -1);
62
63timethese 100000, {
64 empty => '&a; &a',
65 method => '$a->b(5); $a->b(6)',
66 cede => 'cede',
67 transfer0=> 'transfer($main, $c0, 0)',
68 transfer1=> 'transfer($main, $c1, -1)',
69}; 56};
70 57
58$c1 = new Coro::State sub {
59 doit1(1,2,3,4,5,6,7,8,9);
60};
61
62$c0->save (0);
63$c1->save (-1);
64
65transfer($main, $c0);
66transfer($main, $c1);
67
68timethese 1000000, {
69 function => 'a(5); a(6)',
70 method => '$a->b(5); $a->b(6)',
71 cede => 'cede',
72 transfer0 => 'transfer($main, $c0)',
73 transfer1 => 'transfer($main, $c1)',
74};
75
76
77

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines