Dust if (linkedin fork)

JavaScript performance comparison

Revision 5 of this test case created by Takeshi Miya

Preparation code

<script src="http://gunta.org/experimental/dust/dust-full-1.0.0.js"></script>
<script src="http://dl.dropbox.com/u/7677927/hogan-2.0.0.js"></script>

<script>
var data = {
  "name": "Mick",
  "count": 30
};

var tmpl1 = dust.compile('Hello {name}! You have {count} new messages.', "tmpl1");
var tmpl2 = dust.compile('Hello {name}! You have {@if cond="({count} > 0)"}{count} new messages.{/if}', "tmpl2");
var tmpl4 = dust.compile('Hello {name}! You have {?count} {count} new messages {/count}', "tmpl4");

var tmpl3 = Hogan.compile('Hello {{name}}! You have {{count}} new messages.');

dust.loadSource(tmpl1);
dust.loadSource(tmpl2);
dust.loadSource(tmpl4);
</script>
    

Preparation code output

<script src="http://dl.dropbox.com/u/7677927/hogan-2.0.0.js"></script> <script> var data = { "name": "Mick", "count": 30 }; var tmpl1 = dust.compile('Hello {name}! You have {count} new messages.', "tmpl1"); var tmpl2 = dust.compile('Hello {name}! You have {@if cond="({count} > 0)"}{count} new messages.{/if}', "tmpl2"); var tmpl4 = dust.compile('Hello {name}! You have {?count} {count} new messages {/count}', "tmpl4"); var tmpl3 = Hogan.compile('Hello {{name}}! You have {{count}} new messages.'); dust.loadSource(tmpl1); dust.loadSource(tmpl2); dust.loadSource(tmpl4); </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
Dust render without if
dust.render("tmpl1", data, function(err, out) {
});
pending…
Dust render with if
dust.render("tmpl2", data, function(err, out) {
});
pending…
HoganJS
tmpl3.render(data);
pending…
dust render with exists
dust.render("tmpl4", data, function (err, out) {
});
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