--- cvsroot/Coro/eg/bench 2001/07/03 05:05:45 1.1 +++ cvsroot/Coro/eg/bench 2001/07/14 22:14:21 1.3 @@ -10,31 +10,28 @@ $a = bless {}, main::; -# do something similar, switch two global vars and return something sub a { - $old = $current; - $current = $_[0]; + $n++; # do something to taint the benchmark results ;) } $b = new Coro sub { # do a little unrolling... while() { - $Coro::main->resume; $Coro::main->resume; $Coro::main->resume; + yield; yield; yield; yield; yield; } }; -$b->resume; # the first resume is slow because it allocates all the memory +yield; $main = $Coro::main; -sub transfer { - Coro::_transfer($_[0], $_[1]); -} +*transfer = \&Coro::State::transfer; -$c = Coro::_newprocess { +$c = Coro::State::newprocess { while() { - transfer($c, $main); transfer($c, $main); transfer($c, $main); + transfer($c, $main); transfer($c, $main); + transfer($c, $main); transfer($c, $main); } }; @@ -42,6 +39,6 @@ timethese 100000, { method => '$a->a; $a->a; $a->a; $a->a', - resume => '$b->resume; $b->resume', + resume => 'yield; yield', transfer => 'transfer($main, $c); transfer($main, $c)', };