parseInt vs replace vs split (v4)

Revision 4 of this benchmark created by john on


Description

what is faster

var size = "100px";

parseInt(size, 10); +size.replace('px',''); +size.split('p')[0]; parseFloat(size, 10);

Setup

size = "100px";

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt
parseInt(size, 10);
ready
replace
+size.replace('px','');
 
ready
split
+size.split('p')[0];
ready
parseFloat
parseFloat(size, 10);
ready

Revisions

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