Number() vs parseInt() vs plus vs bitwise (v34)

Revision 34 of this benchmark created by anru on


Setup

function fx() {
   return String(Math.random()*10000);
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Number Constructor
Number(fx());
ready
parseInt
parseInt(fx());
ready
Plus operator
+fx();
ready
Bitwise >> (right shift)
fx() >> 0;
ready
Multiply (force cast)
fx() * 1;
ready
Bitwise NOT
~~fx();
ready
parseInt with base argument
parseInt(fx(), 10);
ready
Bitwise OR
fx() | 0
ready
minus 0
fx() - 0;
ready
JSON.parse()
JSON.parse(fx())
ready
parseFloat
parseFloat(fx(), 10)
ready
Math.floor
Math.floor(fx())
ready

Revisions

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