Number() vs parseInt() vs plus vs bitwise (v50)

Revision 50 of this benchmark created on


Setup

var x = Math.random()*10000 + '';

Test runner

Ready to run.

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

Revisions

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