Number() vs parseInt() vs plus vs bitwise (v102)

Revision 102 of this benchmark created on


Setup

var n = "" + Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);

Test runner

Ready to run.

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

Revisions

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