Math.floor vs Math.round vs parseInt vs Bitwise

JavaScript performance comparison

Revision 14 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.round
Math.round(89.938 / 293.3);
Math.round(83784 / 9289.2);
Math.round(7 / 60);
pending…
Math.floor
Math.floor(89.938 / 293.3);
Math.floor(83784 / 9289.2);
Math.floor(7 / 60);
pending…
Math.ceil
Math.ceil(89.938 / 293.3);
Math.ceil(83784 / 9289.2);
Math.ceil(7 / 60);
pending…
parseInt
parseInt(89.938 / 293.3);
parseInt(83784 / 9289.2);
parseInt(7 / 60);
pending…
Bitwise OR
89.938 / 293.3 | 0;
83784 / 9289.2 | 0;
7 / 60 | 0;
pending…
Bitwise Right-Shift
89.938 / 293.3 >> 0;
83784 / 9289.2 >> 0;
7 / 60 >> 0;
pending…
Bitwise Left-Shift
89.938 / 293.3 << 0;
83784 / 9289.2 << 0;
7 / 60 << 0;
pending…
Two's Complement Twice
~~(89.938 / 293.3);
~~(83784 / 9289.2);
~~(7 / 60);
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