Math.floor vs Math.round vs parseInt vs Bitwise

JavaScript performance comparison

Revision 114 of this test case created

Info

Rounding in all form possible

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Math.floor
var floor = Math.floor;
floor(89.938 / 293.3);
floor(83784 / 9289.2);
floor(7 / 60);
return floor;
pending…
Math.round
var round = Math.round;
round(89.938 / 293.3);
round(83784 / 9289.2);
round(7 / 60);
return round;
pending…
parseInt
var pInt = parseInt;
pInt(89.938 / 293.3);
pInt(83784 / 9289.2);
pInt(7 / 60);
return pInt;
pending…
Bitwise |
var round = Math.round;
89.938 / 293.3 | 0;
83784 / 9289.2 | 0;
7 / 60 | 0;
return round;
pending…
Bitwise >>
var round = Math.round;
89.938 / 293.3 >> 0;
83784 / 9289.2 >> 0;
7 / 60 >> 0;
pending…
Bitwise ~~
~~(89.938 / 293.3);
~~(83784 / 9289.2);
~~(7 / 60);
pending…
Bitwise <<
89.938 / 293.3 << 0;
83784 / 9289.2 << 0;
7 / 60 << 0;
pending…
Bitwise >>>
89.938 / 293.3 >>> 0;
83784 / 9289.2 >>> 0;
7 / 60 >>> 0;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment