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
<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/mustache-0.7.2.js"></script>
<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/handlebars.1.0.0-rc.3.js"></script>
<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/hogan-2.0.0.js"></script>
<script src="http://paularmstrong.github.io/swig/js/swig.min.js"></script>
<script src="http://jlongster.github.io/nunjucks/files/nunjucks.min.js"></script>
<!--External Template Definitions-->
<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.nunjucksTemplate = "<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 item in list %}<li class='item'>{{ item }}</li>{% endfor %}</ul></div>";
window.nunjucksCompiledTemplate = new nunjucks.Template(nunjucksTemplate, true);
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.mustacheCompiledTemplate = Mustache.compile(mustacheTemplate);
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.swigTemplate = "<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 item in list %}<li class='item'>{{ item }}</li>{% endfor %}</ul></div>";
window.swigPrecompiledTemplate = swig.compile(swigTemplate);
Handlebars.template((function(){var a=Handlebars.template,b=Handlebars.templates=Handlebars.templates||{};b["template-handlebars.html"]=a(function(a,b,c,d,e){function k(a,b){var c="";return c+="<li class='item'>"+i(typeof a===h?a.apply(a):a)+"</li>",c}this.compilerInfo=[2,">= 1.0.0-rc.3"],c=c||a.helpers,e=e||{};var f="",g,h="function",i=this.escapeExpression,j=this;f+="<div><h1 class='header'>",(g=c.header)?g=g.call(b,{hash:{},data:e}):(g=b.header,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h1><h2 class='header2'>",(g=c.header2)?g=g.call(b,{hash:{},data:e}):(g=b.header2,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h2><h3 class='header3'>",(g=c.header3)?g=g.call(b,{hash:{},data:e}):(g=b.header3,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h3><h4 class='header4'>",(g=c.header4)?g=g.call(b,{hash:{},data:e}):(g=b.header4,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h4><h5 class='header5'>",(g=c.header5)?g=g.call(b,{hash:{},data:e}):(g=b.header5,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h5><h6 class='header6'>",(g=c.header6)?g=g.call(b,{hash:{},data:e}):(g=b.header6,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h6><ul class='list'>",g=c.each.call(b,b.list,{hash:{},inverse:j.noop,fn:j.program(1,k,e),data:e});if(g||g===0)f+=g;return f+="</ul></div>",f})})());
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>");
window.Fmustache= function(data){var o='';var func=[];func[0]=function(data){o+='<li class=\'item\'>';o+='{'+data+'}';o+='</li>';};o+='<div><h1 class=\'header\'>';o+=''+data.header+'';o+='</h1><h2 class=\'header2\'>';o+=''+data.header2+'';o+='</h2><h3 class=\'header3\'>';o+=''+data.header3+'';o+='</h3><h4 class=\'header4\'>';o+=''+data.header4+'';o+='</h4><h5 class=\'header5\'>';o+=''+data.header5+'';o+='</h5><h6 class=\'header6\'>';o+=''+data.header6+'';o+='</h6><ul class=\'list\'>';if(data.hasOwnProperty('list') && data.list){if(typeof data.list === 'object'){if(data.list instanceof Array){for(var i=0;i<data.list.length;i++) func[0](data.list[i]);}else{for(var i in data.list) func[0](data.list[i]);}}else if(typeof data.list === 'function'){if(data.list(data)) func[0](data);}else{ func[0](data.list); }}o+='</ul></div>';return o;
}
window.Fmustache2=function (data){
var o='<div><h1 class=\'header\'>'+(data.header1)+'</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 l=data.list.length,i=0,list=data.list;i<l;i++){
o+='<li class=\'item\'>'+(list[i])+'</li>';
}
o+='</ul></div>';
return o;
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
mustache.js |
| ready |
underscore.js |
| ready |
handlebar.js |
| ready |
handlebar.js (precompiled) |
| ready |
Hogan.js |
| ready |
Fmustache |
| ready |
Swig |
| ready |
Swig Precompiled |
| ready |
Mustache (compiled) |
| ready |
Nunjucks (compiled) |
| ready |
Nunjucks |
| ready |
Fmustache2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.