--- cvsroot/Coro/eg/bench 2001/07/21 19:53:29 1.7 +++ cvsroot/Coro/eg/bench 2001/07/23 02:14:19 1.8 @@ -8,6 +8,8 @@ use Coro; use Benchmark; +sub a() { } + $a = bless {}, main::; sub b { @@ -19,35 +21,50 @@ $b = async { # do a little unrolling... while() { - yield; yield; yield; yield; yield; + cede; cede; cede; cede; cede; } }; -yield; +cede; $main = $Coro::main; *transfer = \&Coro::State::transfer; -sub doit { +sub doit0 { + while() { + # some unrolling here as well.. + transfer($c0, $main); transfer($c0, $main); + transfer($c0, $main); transfer($c0, $main); + transfer($c0, $main); transfer($c0, $main); + } +} + +sub doit1 { while() { # some unrolling here as well.. - transfer($c, $main); transfer($c, $main); - transfer($c, $main); transfer($c, $main); - transfer($c, $main); transfer($c, $main); + transfer($c1, $main); transfer($c1, $main); + transfer($c1, $main); transfer($c1, $main); + transfer($c1, $main); transfer($c1, $main); } } -$c = Coro::State::_newprocess [sub { - doit(1,2,3,4,5,6,7,8,9); +$c0 = Coro::State::_newprocess [sub { + doit0(1,2,3,4,5,6,7,8,9); +}]; + +$c1 = Coro::State::_newprocess [sub { + doit1(1,2,3,4,5,6,7,8,9); }]; -transfer($main, $c); +transfer($main, $c0); +transfer($main, $c1); timethese 100000, { empty => '&a; &a', method => '$a->b(5); $a->b(6)', - yield => 'yield', - transfer => 'transfer($main, $c)', + cede => 'cede', + transfer0=> 'transfer($main, $c0, 0)', + transfer1=> 'transfer($main, $c1)', };