Math.Floor vs ~~ vs parseInt on strings (v11)

Revision 11 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor(string)
var final = Math.floor("3.14");
ready
~~string
var final = ~~"3.14";
ready
parseInt(string)
var final = parseInt("3.14");
ready
string |0
var final = "3.14" | 0;
ready
Math.floor(number)
var final = Math.floor(3.14);
ready
~~number
var final = ~~3.14;
ready
parseInt(number)
var final = parseInt(3.14);
ready
number |0
var final = 3.14 | 0;
ready

Revisions

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