Number() vs parseInt() vs plus vs bitwise (v89)

Revision 89 of this benchmark created by pashoo on


Setup

var x = "456";
    function _mathFloor(str){
      return Math.floor(str);
    }

Test runner

Ready to run.

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

Revisions

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