Math.floor Speed Test 2

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  
    function randInt(a,b){
       return Math.round(  (a-0.5) + Math.random()  * (b-a+1) )
    }
    var p1=randInt(1,10),p2=randInt(1,10),q1,q2;
    while(p1--)
    q1=randInt(1,99);
    while(p2--)
    q2=randInt(110,990);
    
    var num=q2+q1/100;
  
   window.num=num;
  
  

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Test1
window.num2 = ~~ window.num
pending…
Test2
window.num2 = window.num | 0
pending…
Test3
window.num2 = window.num << 0
pending…
Test4
window.num2 = window.num >> 0
pending…
Test5
window.num2 = window.num >>> 0
pending…
Test6
window.num2 = Math.floor(window.num)
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments