Math.Floor vs ~~ (v10)

Revision 10 of this benchmark created on


Setup

var a = Math.random() * 10;
    var b = Math.random() * 10;
    var t;

Teardown


    if (result !== Math.floor(a) && result !== Math.floor(b)) {
      throw "error";
    }
  

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
t = a; a = b; b = t;
var result = Math.floor(a);
ready
~~
t = a; a = b; b = t;
var result = ~~a;
 
ready

Revisions

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