some bugs and remark

Allright, I'm willing to admit when I'm wrong and it seems I am wrong about the bitshifting. I took a closer look at the test on businnessintelligence's website and while I don't see anything wrong with it, I ran my own as suggested and the results were interesting if not exaclty staggering.

Code:
stage.addEventListener( MouseEvent.CLICK, click );

function click( e:MouseEvent ):void
{
   var time:int = getTimer();
   var count:int = 1;
   for( var i:int = 0; i < 1000000; ++i )
   {
      count = 10 >> 1;
   }
   time = (getTimer() - time);
   trace( count );
   trace( time );
   
   time = getTimer();
   for( var i:int = 0; i < 1000000; ++i )
   {
      count = 10 / 2;
   }
   time = (getTimer() - time);
   trace( count );
   trace( time )
}


you can copy that exactly onto any timeline object and run it to see what I am talking about. Basically, at 1 million iterations, the trace results round to 4 and 8 milliseconds each, seems pretty compellingly like a huge speed up right? Well its a bit more clear when run at 50 million iterations... what makes me happy about the validity of these results is the deterministic quality. I can run this test over and over( just click ) and the results are only off by maybe a millisecond or two. Not bad for 50 million iterations.
>>1
208
/2
393

Still, while it is a 89% increase in speed it is only actually worth anything over a rediculously large number of iterations.
Plus, I'd like to point out that this function isn't actually doing anything. In reality its just assigning the value 5 to the count variable and a smart optimizer would just replace that with count = 5;

Wait, that gives me an idea. I'll just check that for results and while I'm at it, I'm going to make the function actually do some work.

New Code.
Code:
function click( e:MouseEvent ):void
{
   var time:int = getTimer();
   //var count:int = 1;
   for( var i:int = 0; i < 50000000; ++i )
   {
      var count:int = int(i >> 1);
   }
   time = (getTimer() - time);
   trace( count );
   trace( time );
   
   time = getTimer();
   for( var i:int = 0; i < 50000000; ++i )
   {
      var count:int = int(i * 0.5);
   }
   time = (getTimer() - time);
   trace( count );
   trace( time )
   
   time = getTimer();
   for( var i:int = 0; i < 50000000;++i )
   {
      var count:int = 5;
   }
   time = (getTimer() - time);
   trace( count );
   trace( time )
}


the results are:
i>>1
211
i*0.5
387
=5
209

If it will make box2d faster... I really don't know. As I said about the broadphase, I'm not sure its worth putting any time into since its likely to be replaced soon.
Are you guys using the debug player or the release one. You MUST use the release one apparrently, or else results are meaningless. There is much FUBAR on the web thanks to this, to the point I'd recommend noting that your aware of this fact every time you post benchmark data.
(of course, that fact might be rubbish, too. I've not run the tests to verify for myself).
vengant : ok, but maybe there are other method who use / or * by 2468 ... i will look at this.
no, i check all the files with a regular expression but all the *2 or /2 used with int are in the same file : b2BroadPhase.as


boris : good point, you remember me that i make all my bench in debug mode, i add the new result for the release mode.
i have made the bench (bitwise and InPoints) with the debug player and the release player but there's no change when you publish the swf in release mode ! (i use FD3)

debug :
------------------ InPointsOriginal ------------------
9487 Millieme
------------------ InPointsLolo ------------------
3394 Millieme
------------------ InPointsOriginal ------------------
9296 Millieme
------------------ InPointsLolo ------------------
3401 Millieme
------------------ InPointsOriginal ------------------
10242 Millieme
------------------ InPointsLolo ------------------
3389 Millieme

release :
------------------ InPointsOriginal ------------------
5709 Millieme
------------------ InPointsLolo ------------------
1257 Millieme
------------------ InPointsOriginal ------------------
5842 Millieme
------------------ InPointsLolo ------------------
1033 Millieme
------------------ InPointsOriginal ------------------
5930 Millieme
------------------ InPointsLolo ------------------
1030 Millieme



and for the bitwise operator against /2 :

debug :
------------------ x / 2 ------------------
1475 Millieme
------------------ x >> 1 ------------------
552 Millieme
------------------ x / 2 ------------------
855 Millieme
------------------ x >> 1 ------------------
718 Millieme
------------------ x / 2 ------------------
854 Millieme
------------------ x >> 1 ------------------
708 Millieme
------------------ x / 2 ------------------
851 Millieme
------------------ x >> 1 ------------------
710 Millieme

release :
------------------ x / 2 ------------------
177 Millieme
------------------ x >> 1 ------------------
88 Millieme
------------------ x / 2 ------------------
174 Millieme
------------------ x >> 1 ------------------
88 Millieme
------------------ x / 2 ------------------
173 Millieme
------------------ x >> 1 ------------------
88 Millieme
------------------ x / 2 ------------------
174 Millieme
------------------ x >> 1 ------------------
88 Millieme


the gap is growing a lot ..

Original thread: https://box2d.org/forum/viewtopic.php?t=3013