Number() vs parseInt() vs plus vs bitwise (v46)

Revision 46 of this benchmark created on


Setup

// Note: if you use constants in a loop, you are really testing the JIT compiler's ability to detect loop a invariant.
  var my_num = "10";

Test runner

Ready to run.

Testing in
TestOps/sec
Number Constructor
Number("10");
ready
parseInt
parseInt("10", 10);
ready
Parse Float
parseFloat("10");
ready
Number Constructor - Variable
Number(my_num);
ready
parseInt - Variable
parseInt(my_num, 10);
ready
Plus operator - Variable
+my_num;
ready
Bitwise >> (right shift) - Variable
my_num >> 0;
ready
Multiply (force cast) - Variable
my_num * 1;
ready
not not - Variable
~~my_num;
ready
Parse Float - Variable
parseFloat(my_num);
ready

Revisions

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