String concat vs regex replace

JavaScript performance comparison

Test case created by

Preparation code

Benchmark.prototype.setup = function() {
  var view = {
    name: "test",
    value: 5
  template = "Hello, my name is {name} and my value is {value}",
  render = function fmt(s,a,r){r=/\{([^}]+)\}/g;return s.replace(r,function(_,m){return a[m]})};


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
String join
//This would be an example of a compiled template
var rendered = "Hello, my name is " + + " and my value is " + view.value;
Using a regex
var rendered = render(template, view);

Compare results of other browsers


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