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

Revision 7 of this benchmark created by Paul Straw on


Description

Rounding in all form possible

Preparation HTML

<script>
  var mfloor = Math.floor,
      mround = Math.round;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
Math.floor(89.938 / 293.3);
Math.floor(83784 / 9289.2);
Math.floor(7 / 60);
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);
parseInt(83784 / 9289.2);
parseInt(7 / 60);
ready
Bitwise |
89.938 / 293.3 | 0;
83784 / 9289.2 | 0;
7 / 60 | 0;
ready
Bitwise
89.938 / 293.3 >> 0;
83784 / 9289.2 >> 0;
7 / 60 >> 0;
ready
floor
mfloor(89.938 / 293.3);
mfloor(83784 / 9289.2);
mfloor(7 / 60);
ready
round
mround(89.938 / 293.3);
mround(83784 / 9289.2);
mround(7 / 60);
ready
Double bitwise ~
~~ (89.938 / 293.3);

~~ (83784 / 9289.2);

~~ (7 / 60);
ready

Revisions

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