Number vs. plus vs. parseInt vs. parseFloat vs. divide by 1 vs. multiply by 1 vs. 1* vs ~~ vs |0 (v31)

Revision 31 of this benchmark created by Alejandro Iglesias on


Setup

var num = "33.5px";

Test runner

Ready to run.

Testing in
TestOps/sec
Number
Number(num);
ready
+
+num;
ready
parseInt
parseInt(num, 10);
ready
parseFloat
parseFloat(num);
ready
parseInt (no extra parameter)
parseInt(num);
ready
divide by 1
num / 1;
ready
multiply by 1
num * 1;
ready
1*
1 * num;
ready
~~
~~
num
ready
|0
num | 0
ready

Revisions

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