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
Underscore Templates vs. raw DOM manipulation.
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<div id="target"></div>
<script>
window.target = document.getElementById("target");
window.underscoreTemplate = _.template("<div><h1 class='header'><%= data.header %></h1><div class='a'><%= data.a %></div><div class='b'><%= data.b %><div class='c'><%= data.c %><div class='d'><%= data.d %><div class='e'><%= data.e %><div class='f'><%= data.f %></div></div></div></div></div></div>", null, {variable: 'data'});
window.simpleCoffeeTemplates3 = {
example: function(a) {
return "<div> <h1 class='header'>" + a.header + "</h1> <h2 class='header2'>" + a.header2 + "</h2> <h3 class='header3'>" + a.header3 + "</h3> <h4 class='header4'>" + a.header4 + "</h4> <h5 class='header5'>" + a.header5 + "</h5> <h6 class='header6'>" + a.header6 + "</h6> <ul> " + (simpleCoffeeTemplates3.loop(a.list, 'li')) + " </ul> </div>";
},
li: function(a) {
return "<li class='item'>" + a + "</li>";
},
loop: function(data, template) {
var a, out, _i, _len;
out = "";
for (_i = 0, _len = data.length; _i < _len; _i++) {
a = data[_i];
out += simpleCoffeeTemplates3[template](a);
}
return out;
}
};
window.sharedVariables = {
header: "Header",
a: 'aaa',
b: 'bbb',
c: 'ccc',
d: 'ddd',
e: 'eee',
f: 'fff'
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Underscore.js Template |
| ready |
DOM Manipulation |
| ready |
Raw CoffeeScript |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.