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
var one = ['foo', 'bar', 'baz', 'bam', 'fizzle'];
var two = ['foo', 'slam', 'okay', 'go!', 'bam', 'fizzle'];
function diffIter(a, b) {
return a.filter(function(value) {
return b.indexOf(value) == -1;
});
}
function diffMap(a, b) {
var length = a.length;
var map = {};
for (var i = 0; i < length; ++i) {
map[a[i]] = true;
}
length = b.length;
for (var i = 0; i < length; ++i) {
delete map[b[i]];
}
return Object.keys(map);
}
function diffMap2(a, b) {
var map = {};
var length = b.length;
for (var i = 0; i < length; ++i) {
map[b[i]] = true;
}
return a.filter(function(value) { return !map[value] });
}
function diffMap3(a, b) {
var result = [];
var map = {};
var length = b.length;
for (var i = 0; i < length; ++i) {
map[b[i]] = true;
}
length = a.length;
for (var i = 0; i < length; ++i) {
if (!map[a[i]]) {
result.push(a[i]);
}
}
return result;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Iter |
| ready |
Map |
| ready |
Map 2 |
| ready |
Map 3 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.