Hogan.js vs. Mustache (v5)

Revision 5 of this benchmark created 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"
        };
      }
    };
    var template = "{{#messages}}{{greeting}}, {{subject}}{{/messages}}{{#citation}}{{authorName}}, {{year}}{{/citation}}";
    var compiled = Hogan.compile(template);

Test runner

Ready to run.

Testing in
TestOps/sec
Rendering with Mustache
var html = Mustache.to_html(template, context);
ready
Rendering with Hogan.js (uncompiled)
var compiledTemplate = Hogan.compile(template);
var html = compiledTemplate.render(context);
 
ready
Rendering with Hogan.js (compiled)
var html = compiled.render(context);
ready

Revisions

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