Replace All vs Split/Join

JavaScript performance comparison

Revision 56 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var str = "Courage of our questions explorations light years something incredible is waiting to be known. A very small stage in a vast cosmic arena venture! Science rich in heavy atoms across the centuries concept of the number one cosmic ocean preserve and cherish that pale blue dot decipherment Sea of Tranquility are creatures of the cosmos kindling the energy hidden in matter! Prime number Rig Veda shores of the cosmic ocean, dispassionate extraterrestrial observer vanquish the impossible descended from astronomers network of wormholes the carbon in our apple pies emerged into consciousness quasar rogue the ash of stellar alchemy dream of the mind's eye! Across the centuries. Emerged into consciousness worldlets!";

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
split & join
str.split("the").join("yjr");
pending…
replace
str.replace(
new RegExp('the'.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), 'gm'), 'yjr');
pending…

Compare results of other browsers

Revisions

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

0 Comments