Replace All vs Split/Join (v38)

Revision 38 of this benchmark created on


Setup

var str = "Test abc test test abc test...",
        REGEX = /abc/g;
    var strs = ["Test abc test test abc test...", "...Test abc test test abc test"];
    var i = 0;
    var result;

Teardown


    window.LEAK = result;
  

Test runner

Ready to run.

Testing in
TestOps/sec
split & join
str.split("abc").join("");
ready
replace
str.replace(REGEX, '');
ready
replace (prevent DCE & LICM)
result = strs[i = ((i + 1) & 1)].replace(REGEX, '');
ready
split & join (prevent DCE&LICM)
result = strs[i = ((i + 1) & 1)].split("abc").join("");
ready

Revisions

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