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.5 by root, Tue Jul 17 15:42:28 2001 UTC vs.
Revision 1.7 by root, Sat Jul 21 19:53:29 2001 UTC

8use Coro; 8use Coro;
9use Benchmark; 9use Benchmark;
10 10
11$a = bless {}, main::; 11$a = bless {}, main::;
12 12
13
14sub a { 13sub b {
15 $n++; # do something to taint the benchmark results ;) 14 my ($self) = shift;
15 $self->{b} = shift if @_;
16 $self->{b};
16} 17}
17 18
18$b = async { 19$b = async {
19 # do a little unrolling... 20 # do a little unrolling...
20 while() { 21 while() {
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 [sub { 32sub doit {
32 while() { 33 while() {
33 # some unrolling here as well.. 34 # some unrolling here as well..
34 transfer($c, $main); transfer($c, $main); 35 transfer($c, $main); transfer($c, $main);
35 transfer($c, $main); transfer($c, $main); 36 transfer($c, $main); transfer($c, $main);
36 transfer($c, $main); transfer($c, $main); 37 transfer($c, $main); transfer($c, $main);
37 } 38 }
39}
40
41$c = Coro::State::_newprocess [sub {
42 doit(1,2,3,4,5,6,7,8,9);
38}]; 43}];
39 44
40transfer($main, $c); 45transfer($main, $c);
41 46
42timethese 100000, { 47timethese 100000, {
48 empty => '&a; &a',
43 method => '$a->a; $a->a', 49 method => '$a->b(5); $a->b(6)',
44 resume => 'yield', 50 yield => 'yield',
45 transfer => 'transfer($main, $c)', 51 transfer => 'transfer($main, $c)',
46}; 52};
47 53

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines