--- cvsroot/Coro/eg/bench 2001/07/03 05:05:45 1.1 +++ cvsroot/Coro/eg/bench 2001/07/17 00:24:15 1.4 @@ -10,38 +10,36 @@ $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 ;) } +$|=1; -$b = new Coro sub { +$b = async { # 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 [sub { while() { - transfer($c, $main); transfer($c, $main); transfer($c, $main); + transfer($c, $main); transfer($c, $main); + transfer($c, $main); transfer($c, $main); } -}; +}]; transfer($main, $c); 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)', };