Math.floor vs Math.round vs parseInt vs Bitwise (v44)

Revision 44 of this benchmark created on


Description

Rounding in all form possible. Testing for rounding behavior by adding .5 to each test other than Math.round.

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
Math.floor(89.938 / 293.3 + .5);
Math.floor(83784 / 9289.2 + .5);
Math.floor(7 / 60 + .5);
ready
Math.round
Math.round(89.938 / 293.3);
Math.round(83784 / 9289.2);
Math.round(7 / 60);
ready
parseInt
parseInt(89.938 / 293.3 + .5);
parseInt(83784 / 9289.2 + .5);
parseInt(7 / 60 + .5);
ready
Bitwise |
(89.938 / 293.3 + .5) | 0;
(83784 / 9289.2 + .5) | 0;
(7 / 60 + .5) | 0;
ready
Bitwise
(89.938 / 293.3 + .5) >> 0;
(83784 / 9289.2 + .5) >> 0;
(7 / 60 + .5) >> 0;
ready

Revisions

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