jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Use html escaping in all test cases if it is not used already
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/underscore-1.4.4.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js"></script>
<script src="http://mustache.github.io/extras/mustache.js"></script>
<script src="http://foo123.github.io/libs/Contemplate-0.6.10.min.js"></script>
<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/kendo.core.min.2013.1.319.js"></script>
<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/hogan-2.0.0.js"></script>
<!--External Template Definitions-->
<script type="text/x-kendo-template" id="kendoUIextTemplate"><div><h1 class='header'>#: data.header #</h1><h2 class='header2'>#: data.header2 #</h2><h3 class='header3'>#: data.header3 #</h3><h4 class='header4'>#: data.header4 #</h4><h5 class='header5'>#: data.header5 #</h5><h6 class='header6'>#: data.header6 #</h6><ul class='list'># for (var i = 0, l = data.list.length; i < l; i++) { #<li class='item'>#: data.list[i] #</li># } #</ul></div></script>
<script type="text/x-contemplate" id="contemplateextTemplate">
<# #>
<div><h1 class='header'><# %e($header) #></h1><h2 class='header2'><# %e($header2) #></h2><h3 class='header3'><# %e($header3) #></h3><h4 class='header4'><# %e($header4) #></h4><h5 class='header5'><# %e($header5) #></h5><h6 class='header6'><# %e($header6) #></h6><ul class='list'><# %for($list as $item) #><li class='item'><# %e($item) #></li><# %endfor() #></ul></div></script>
<script>
window.sharedVariables = {
header: "Header",
header2: "Header2",
header3: "Header3",
header4: "Header4",
header5: "Header5",
header6: "Header6",
list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
};
window.mustacheTemplate = "<div><h1 class='header'>{{header}}</h1><h2 class='header2'>{{header2}}</h2><h3 class='header3'>{{header3}}</h3><h4 class='header4'>{{header4}}</h4><h5 class='header5'>{{header5}}</h5><h6 class='header6'>{{header6}}</h6><ul class='list'>{{#list}}<li class='item'>{{.}}</li>{{/list}}</ul></div>";
window.underscoreTemplate = _.template("<div><h1 class='header'><%- header %></h1><h2 class='header2'><%- header2 %></h2><h3 class='header3'><%- header3 %></h3><h4 class='header4'><%- header4 %></h4><h5 class='header5'><%- header5 %></h5><h6 class='header6'><%- header6 %></h6><ul class='list'><% for (var i = 0, l = list.length; i < l; i++) { %><li class='item'><%- list[i] %></li><% } %></ul></div>");
window.handlebarsTemplate = Handlebars.compile("<div><h1 class='header'>{{header}}</h1><h2 class='header2'>{{header2}}</h2><h3 class='header3'>{{header3}}</h3><h4 class='header4'>{{header4}}</h4><h5 class='header5'>{{header5}}</h5><h6 class='header6'>{{header6}}</h6><ul class='list'>{{#each list}}<li class='item'>{{this}}</li>{{/each}}</ul></div>");
window.kendouiTemplate = kendo.template("<div><h1 class='header'>#: data.header #</h1><h2 class='header2'>#: data.header2 #</h2><h3 class='header3'>#: data.header3 #</h3><h4 class='header4'>#: data.header4 #</h4><h5 class='header5'>#: data.header5 #</h5><h6 class='header6'>#: data.header6 #</h6><ul class='list'># for (var i = 0, l = data.list.length; i < l; i++) { #<li class='item'>#: data.list[i] #</li># } #</ul></div>", {useWithBlock: true});
window.kendouiTemplate2 = kendo.template("<div><h1 class='header'>#: data.header #</h1><h2 class='header2'>#: data.header2 #</h2><h3 class='header3'>#: data.header3 #</h3><h4 class='header4'>#: data.header4 #</h4><h5 class='header5'>#: data.header5 #</h5><h6 class='header6'>#: data.header6 #</h6><ul class='list'># for (var i = 0, l = data.list.length; i < l; i++) { #<li class='item'>#: data.list[i] #</li># } #</ul></div>", {useWithBlock: false});
//Use external template definition
window.kendoUIAlt1 = kendo.template($("#kendoUIextTemplate").html());
window.kendoUIAlt2 = kendo.template($("#kendoUIextTemplate").html(), {useWithBlock: false});
//Use external template definition
Contemplate.add({
'test': "#contemplateextTemplate"
});
window.contemplateTpl = Contemplate.tpl( 'test' );
window.hoganCompile = Hogan.compile("<div><h1 class='header'>{{header}}</h1><h2>class='header2'>{{header2}}</h2><h3 class='header3'>{{header3}}</h3><h4 class='header4'>{{header4}}</h4><h5 class='header5'>{{header5}}</h5><h6 class='header6'>{{header6}}</h6><ul class='list'>{{#list}}<li class='item'>{{.}}</li>{{/list}}</ul></div>");
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
mustache (esc) |
| ready |
underscore (esc) |
| ready |
handlebars 2.0.0 (esc) |
| ready |
Contemplate 0.6.10 (esc) |
| ready |
Kendo UI Templates (Default) (esc) |
| ready |
Kendo UI Templates (No "with" block) (esc) |
| ready |
Hogan (esc) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.