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

Revision 42 of this benchmark created by Marco Pfeiffer on


Setup

var a = 89.938 / 293.3;
  var b = 83784 / 9289.2;
  var c = 7 / 60;

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
Math.floor(a);
Math.floor(b);
Math.floor(c);
ready
Math.round
Math.round(a);
Math.round(b);
Math.round(c);
ready
parseInt
parseInt(a);
parseInt(b);
parseInt(c);
ready
Bitwise |
a | 0;
b | 0;
c | 0;
ready
Bitwise
a >> 0;
b >> 0;
c >> 0;
ready
Bit flipping
~~a;
~~b;
~~c;
ready
zero-fill right shift
a >>> 0;
b >>> 0;
c >>> 0;
ready

Revisions

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