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

Comparing Coro/eg/bench (file contents):
Revision 1.5 by root, Tue Jul 17 15:42:28 2001 UTC vs.
Revision 1.6 by root, Sat Jul 21 18:21:45 2001 UTC

10 10
11$a = bless {}, main::; 11$a = bless {}, main::;
12 12
13 13
14sub a { 14sub a {
15 $n++; # do something to taint the benchmark results ;) 15}
16
17sub b {
18 my ($self) = shift;
19 my $num = shift;
20 return $num+1;
16} 21}
17 22
18$b = async { 23$b = async {
19 # do a little unrolling... 24 # do a little unrolling...
20 while() { 25 while() {
26 31
27$main = $Coro::main; 32$main = $Coro::main;
28 33
29*transfer = \&Coro::State::transfer; 34*transfer = \&Coro::State::transfer;
30 35
31$c = Coro::State::_newprocess [sub { 36sub doit {
32 while() { 37 while() {
33 # some unrolling here as well.. 38 # some unrolling here as well..
34 transfer($c, $main); transfer($c, $main); 39 transfer($c, $main); transfer($c, $main);
35 transfer($c, $main); transfer($c, $main); 40 transfer($c, $main); transfer($c, $main);
36 transfer($c, $main); transfer($c, $main); 41 transfer($c, $main); transfer($c, $main);
37 } 42 }
43}
44
45$c = Coro::State::_newprocess [sub {
46 doit(1,2,3,4,5,6,7,8,9);
38}]; 47}];
39 48
40transfer($main, $c); 49transfer($main, $c);
41 50
42timethese 100000, { 51timethese 100000, {
52 empty => '&a; &a',
43 method => '$a->a; $a->a', 53 method => '$a->b(5); $a->b(6)',
44 resume => 'yield', 54 yield => 'yield',
45 transfer => 'transfer($main, $c)', 55 transfer => 'transfer($main, $c)',
46}; 56};
47 57

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines