Handlebars-vs-Mini-Handlebars

JavaScript performance comparison

Revision 3 of this test case created by Mike Smullin

Preparation code

<script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.rc.1.js"></script>
<script src="https://raw.github.com/mikesmullin/mini-handlebars/production/js/mini-handlebars.js"</script>
      
<script>
Benchmark.prototype.setup = function() {
  mini = new MiniHandlebars({
    locals: {
      each: function(template, data, enumerable, key, value) {
        var k, out, v, _data, _k, _ref;
        out = '';
        _ref = data[enumerable];
        for (k in _ref) {
          if (!__hasProp.call(_ref, k)) continue;
          v = _ref[k];
          _data = {};
          for (_k in v) {
            if (!{}.hasOwnProperty(v, _k)) {
              _data[_k] = v[_k];
            }
          }
          if (typeof key !== 'undefined') {
            _data[key] = k;
          }
          if (typeof value !== 'undefined') {
            _data[value] = v;
          }
          out += mini.render(template, _data);
        }
        return out;
      }
    }
  });
  
  var source   = '<ul class="people_list">\n{{#each people}}\n<li>{{this}}</li>\n{{/each}}\n</ul>';
  
  var template = '<ul class="people_list">\n{{each people}}\n<li>{{this}}</li>\n{{/each}}\n</ul>';
  
  var data = {
    people: ["Yehuda Katz", "Alan Johnson", "Charles Jolley"]
  };

};
</script>

Preparation code output

<script src="https://raw.github.com/mikesmullin/mini-handlebars/production/js/mini-handlebars.js"</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
Handlebars
Handlebars.compile(source)(data);
pending…
Mini-Handlebars
mini.render(template, data);
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