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 arr = [1, 2, 4, 4, 3, 3, 1, 5, 3];
var dupIndexCheck = function() {
var dupes = [];
for (var i = 0, len = arr.length; i < len; i++) {
var val = arr[i];
if (dupes.indexOf(val) === -1 && arr.indexOf(val) !== arr.lastIndexOf(val)) {
dupes.push(val);
}
}
return dupes;
}
var dupOccurCount = function() {
var seen = {};
var dupes = [];
for (var i = 0, len = arr.length; i < len; i++) {
seen[arr[i]] = seen[arr[i]] ? seen[arr[i]] + 1 : 1;
}
for (var item in seen) {
if (seen.hasOwnProperty(item) && seen[item] > 1) {
dupes.push(item);
}
}
return dupes;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
IndexOf |
| ready |
countOccur |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.