Mustache.js vs Hogan.js ver 1.0.5 vs ejs

Benchmark created by aloha on


Preparation HTML

<div id ="result">
</div>
<!-- hogan - mustache template -->
<script id="demo" type="text/template">
                <p>{{title}}</p>
                <ul>
                    {{#items}}
                    <li>
                        {{title}}
                    </li>
                    {{/items}}
                </ul>
</script>
<!-- //end template-->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<!-- script mustache -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.7.0/mustache.min.js" type="text/javascript"></script>
<!-- //end script --> 
<!-- script EJS -->
<script src="http://embeddedjavascript.googlecode.com/files/ejs_production.js"></script>
<script src="http://code.google.com/p/embeddedjavascript/source/browse/trunk/src/ejs.js"></script>
<!-- // end script -->

<!-- script hogan -->
<script src="http://twitter.github.com/hogan.js/builds/1.0.5/hogan-1.0.5.js"></script>
<!-- //end script -->

Setup

var data = {
      title: "Title - example 1",
      link: "/",
      description: "JavaScript -  Title - example 1",
      language: "en",
      items: [{
        title: "Sub title 1",
        link: "/",
        description: "Decription - sub title 1 - Decription - sub title 1 - Decription - sub title 1 - Decription - sub title 1- Decription - sub title 1 "
      }, {
        title: "Sub title 2",
        link: "/",
        description: "Decription - sub title 2 - Decription - sub title 2 - Decription - sub title 2 - Decription - sub title 2- Decription - sub title 2 "
      }, {
        title: "Sub title 3",
        link: "/",
        description: "Decription - sub title 3 - Decription - sub title 3 - Decription - sub title 3 - Decription - sub title 3- Decription - sub title 3 "
      }]
    
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Rendering with Mustache
var template = document.getElementById("demo").innerHTML;
var html = Mustache.to_html(template, data);
document.getElementById("result").innerHTML = html;
ready
Rendering with Hogan
var str_template = document.getElementById("demo").innerHTML;
var template = Hogan.compile(str_template);
var html = template.render(data);
document.getElementById("result").innerHTML = html;
ready

Revisions

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

  • Revision 1: published by aloha on