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
compare _.each with _.map with native while
<script src="http://underscorejs.org/underscore.js"></script>
var a = [];
var strings = ['dogs', 'cats', 'mice', 'ohmy', 'cowardice'];
var s;
_.times(50, function(n) {
s = strings[Math.floor(n / 10)] + ":" + strings[n % 5] + ":" + Math.floor((n % 10) / 5);
a.push({
num: n,
string: s
});
});
function getNum(e) {
var split = e.string.split(":");
var tens = split[0],
ones = split[1],
high = split[2];
return strings.indexOf(tens) * 10 + strings.indexOf(ones) + 5 * high;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
_.each |
| ready |
_.map |
| ready |
native for loop |
| ready |
native map |
| ready |
native for, cached |
| ready |
native for, cached |
| ready |
native while |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.