Hogan.js vs. Mustache (v2)

Revision 2 of this benchmark created by Divya Manian on


Description

Updated the test to not add to innerHTML nor depend on jQuery as it might infringe on the real performance.

Preparation HTML

<script src="//goo.gl/OCK7V"></script>
<script src="https://raw.github.com/janl/mustache.js/master/mustache.js"></script>

Setup

var context = {
      messages: [
        { greeting: "Hello", subject: "World" },
        { greeting: "What's up", subject: "Dan" },
        { greeting: "How's it going", subject: "Ben?" },
        { greeting: "Hello", subject: "World" },
        { greeting: "What's up", subject: "Dan" },
        { greeting: "How's it going", subject: "Ben?" },
        { greeting: "Hello", subject: "World" },
        { greeting: "What's up", subject: "Dan" },
        { greeting: "How's it going", subject: "Ben?" },
        { greeting: "Hello", subject: "World" }
      ],
    
      "citation": function() {
        return {
          authorName: "Dan Gilbert",
          year: "2011"
        };
      }
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Rendering with Mustache
var template = "{{#messages}}{{greeting}}, {{subject}} {{/messages }}{{#citation}}{{authorName}}, {{year}}{{/citation}}";
var html = Mustache.to_html(template, context);
 
ready
Rendering with Hogan.js (uncompiled)
var template = "{{#messages}}{{greeting}}, {{subject}}{{/messages}}{{#citation}}{{authorName}}, {{year}}{{/citation}}";
var compiledTemplate = Hogan.compile(template);
var html = compiledTemplate.render(context);
 
ready

Revisions

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