replace() or substr() (v17)

Revision 17 of this benchmark created on


Setup

var str = "15785-985";
    var regEx = /\.$/;

Test runner

Ready to run.

Testing in
TestOps/sec
substr
str = str.substr(0, 5)+str.substr(6, 3);
ready
replace
str = str.replace('-', '');
ready
precompiled replace
str = str.replace(regEx, '');
ready

Revisions

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