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="https://underscorejs.org/underscore-min.js"></script>
var products = [{
name: "Sonoma",
ingredients: ["artichoke", "sundried tomatoes", "mushrooms"],
containsNuts: false
}, {
name: "Pizza Primavera",
ingredients: ["roma", "sundried tomatoes", "goats cheese", "rosemary"],
containsNuts: false
}, {
name: "South Of The Border",
ingredients: ["black beans", "jalapenos", "mushrooms"],
containsNuts: false
}, {
name: "Blue Moon",
ingredients: ["blue cheese", "garlic", "walnuts"],
containsNuts: true
}, {
name: "Taste Of Athens",
ingredients: ["spinach", "kalamata olives", "sesame seeds"],
containsNuts: true
}];
function ic(p,o,i,b,g) {
i|=0;g|=0;
if(!b&&p&&!p.ingredients)
while((g=ic(p[g].ingredients,o,0,g+1))&&p[g]);
else {
o[p[i]]=(o[p[i]]|0)+1;
return p[i+1]?ic(p,o,i+1,b):b;
}
}
function ic2(ps) {
return ps.reduce(function (r, p) {
p.ingredients.forEach(function (i) {
r[i] = (r[i] || 0) + 1;
});
return r;
}, {});
}
Ready to run.
Test | Ops/sec | |
---|---|---|
underscore |
| ready |
recursion |
| ready |
plain JS |
| ready |
plain js function |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.