Weld vs Mustach

JavaScript performance comparison

Test case created by Joshua Kehn

Preparation code

<script src="http://mustache.github.com/extras/mustache.js"></script>
<script src="https://raw.github.com/hij1nx/weld/master/lib/weld.js"></script>

<div id="welddiv">
  <h1 id="name">My Name</h1>
  <ul><li class="interests">An interest</li></ul>
</div>

<div id="mustachediv">
   <h1>{{name}}</h1>
   {{#items}}
     <li>{{interests}}</li>
   {{/items}}
</div>
<div id="mustachediv-saved">
   <h1>{{name}}</h1>
   {{#items}}
     <li>{{interests}}</li>
   {{/items}}
</div>
<script>
Benchmark.prototype.setup = function() {
    var me = {
      "name": "Joshua Kehn",
      "interests" : [
        "javascript",
        "node.js",
        "development",
        "programming"
      ]
    };
   
    var weld_elem = document.getElementById('welddiv');
   
    var me_stach = {
      "name": "Joshua Kehn",
      "interests" : [
        {"interest":"javascript"},
        {"interest":"node.js"},
        {"interest":"development"},
        {"interest":"programming"}
      ]
    };
   
    var m_elem = document.getElementById('mustachediv');
    var m_saved = document.getElementById('mustachediv-saved');
};
</script>

Preparation code output

My Name

  • An interest

{{name}}

{{#items}}
  • {{interests}}
  • {{/items}}

    {{name}}

    {{#items}}
  • {{interests}}
  • {{/items}}

    Test runner

    Warning! For accurate results, please disable Firebug before running the tests. (Why?)

    Java applet disabled.

    Testing in unknown unknown
    Test Ops/sec
    Weld
    weld(weld_elem, me);
    pending…
    Mustache
    m_elem.innerHTML = Mustache.to_html(m_saved.innerHTML, me_stach);
    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. Here’s a list of current revisions for this page:

    0 comments

    Add a comment