Number() vs parseInt() vs plus vs bitwise (v69)

Revision 69 of this benchmark created by Ginden on


Setup

var number = Math.floor(Math.random() * Date.now() / 10000) + '';
    eval({});

Test runner

Ready to run.

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

Revisions

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