Template, Mustache.js, Hogan.js and Templayed comparison

JavaScript performance comparison

Revision 4 of this test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/mootools/1.4/mootools-yui-compressed.js"></script><script src="https://raw.github.com/tbela99/template/master/Source/Template.js"></script><script src="https://raw.github.com/janl/mustache.js/master/mustache.js"></script><script src="https://raw.github.com/twitter/hogan.js/master/lib/template.js"></script>
<script src="https://raw.github.com/twitter/hogan.js/master/lib/compiler.js"></script>
<script src="https://raw.github.com/archan937/templayed.js/master/src/templayed.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
    var template = new Template(),
  	render = template.compile('{title} spends {calc}');
    
      var view = {
        title: "Joe",
        calc: function() {
          return 2 + 4;
        }
      },
  	compiled = Hogan.compile("{{title}} spends {{calc}}"),
    tpl = templayed("{{title}} spends {{calc}}");
  	

};
</script>

Preparation code output

<script src="https://raw.github.com/tbela99/template/master/Source/Template.js"></script><script src="https://raw.github.com/janl/mustache.js/master/mustache.js"></script><script src="https://raw.github.com/twitter/hogan.js/master/lib/template.js"></script> <script src="https://raw.github.com/twitter/hogan.js/master/lib/compiler.js"></script> <script src="https://raw.github.com/archan937/templayed.js/master/src/templayed.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
Mustache
Mustache.to_html("{{title}} spends {{calc}}", view)
pending…
Hogan
compiled.render(view)
pending…
precompiled Template
render(view)
pending…
Template
template.substitute('{title} spends {calc}', view)
pending…
Templayed
tpl(view)
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