replace() or substr() (v19)

Revision 19 of this benchmark created by Shane on


Setup

var str = "a.aa.a.aa.";
    var regEx = /\.$/;

Test runner

Ready to run.

Testing in
TestOps/sec
substr
str = str.substr(0, str.length - 1);
ready
replace
str = str.replace(/\.$/, '');
ready
precompiled replace
str = str.replace(regEx, '');
ready
String replace
str = str.replace("a.", "");
ready
Substr 1 parameter
var str = "page_11";
str = str.substr(5);
ready
Substr 2 parameters
var str = "page_11";
str = str.substr(5, str.length);
ready

Revisions

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