Initial check-in of perl compiler.
[p5sagit/p5-mst-13.2.git] / ramblings / foo.bench
1 # The following doesn't work: if $foo_ir and $bar_ir aren't initialised
2 # then when we hit the $bar += $foo_ir in the middle of the loop for the
3 # first time, we trigger a load_int for $bar_ir from its backing SV.
4 # We don't write-back the shadow variable into the SV at the end of the
5 # loop (which we ought to cope with) and so the next time through the loop
6 # we're in the wrong state.
7 # my ($foo_ir, $bar_ir);
8 use integer;
9 # If we initialise explicitly here then we're OK since INT_VALID is then set
10 # by the time we're in the loop and so we don't have to reload from the SV
11 my $foo_ir = 0;
12 my $bar_ir = 0;
13
14 for ($foo_ir = 0; $foo_ir < 3000000; $foo_ir += 2) {
15     $bar_ir += $foo_ir;
16 }
17 print "\$foo_ir = $foo_ir, \$bar_ir = $bar_ir\n";
18 #[local/src/B]nonesuch% time ./foo
19 #$foo_ir = 3000000, $bar_ir = -564363104
20 #2.260u 0.090s 0:02.44 96.3% 0+0k 0+0io 89pf+0w
21 #[local/src/B]nonesuch% time perl foo.pl
22 #$foo_ir = 3000000, $bar_ir = -564363104
23 #73.250u 0.090s 1:13.49 99.7% 0+0k 0+0io 130pf+0w