Number() vs parseInt() vs plus vs bitwise (v63)

Revision 63 of this benchmark created on


Setup

var digits = [];
    for (var i=1; i<10; ++i) {
      digits.push(Math.floor(Math.random() * 9) + 1);
    }
    
    numberString = digits.join('');

Test runner

Ready to run.

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

Revisions

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