You may think that this is a silly patch, but it's real. mops.pasm uses a very simple loop to figure out how many operations a second parrot can go. However, the loop it uses is inefficient: it does a "branch" *and* an "eq" every time around. Real code shouldn't do this: I try and explain this at http://www.parrotcode.org/examples/ and it also features at http://java.sun.com/docs/books/vmspec/2nd-edition/html/Compiling.doc.html#4182
The attached patch optimises the loop. Note that MOPS numbers now look slightly different. For example, on my laptop: OLD LOOP mops.pasm: 11.713909 ./mops: 108.442655 with -O3: mops.pasm: 17.030964 ./mops: 240.719673 NEW LOOP mops.pasm: 10.647256 ./mops: 73.574232 with -O3: mops.pasm: 15.141514 ./mops: 150.416772 Of course, the benchmark could be improved, but I suggest we should at least change it to be good, tight code ;-) Leon -- Leon Brocard.............................http://www.astray.com/ Nanoware...............................http://www.nanoware.org/ .... Clones are people two
Index: examples/assembly/mops.pasm =================================================================== RCS file: /home/perlcvs/parrot/examples/assembly/mops.pasm,v retrieving revision 1.1 diff -u -r1.1 mops.pasm --- examples/assembly/mops.pasm 2001/10/15 21:37:07 1.1 +++ examples/assembly/mops.pasm 2001/11/10 19:22:02 @@ -16,7 +16,7 @@ print I4 print "\n" - set I1, 3 + set I1, 2 mul I5, I4, I1 print "Estimated ops: " @@ -25,9 +25,8 @@ time N1 -REDO: eq I2, I4, DONE - add I2, I2, I3 - branch REDO +REDO: add I2, I2, I3 + lt I2, I4, REDO DONE: time N5