--- Coro/eg/bench 2001/07/10 01:43:21 1.2 +++ Coro/eg/bench 2001/07/17 15:42:28 1.5 @@ -10,37 +10,38 @@ $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 { +$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; -#*transfer = \&Coro::_transfer; -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); + # some unrolling here as well.. + 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', - transfer => 'transfer($main, $c); transfer($main, $c)', + method => '$a->a; $a->a', + resume => 'yield', + transfer => 'transfer($main, $c)', }; +