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
function getRandomArbitrary(min, max) {
return Math.round(Math.random() * (max - min) + min);
}
const data = [];
for (let i = 0; i < 10000000; i += 1) {
data.push(getRandomArbitrary(1, 1000));
}
const func1 = (arr) => {
const result = []
for (let i = 0; i < arr.length; i += 1) {
if (result.includes(arr[i])) continue
result.push(arr[i])
}
return result
}
const func2 = (arr) => {
const result = [...new Set(arr)]
return result
}
const func3 = (arr) => {
const hash = {};
const result = [];
for (let i = 0; i < arr.length; i += 1) {
if (hash[arr[i]]) continue;
result.push(arr[i]);
hash[arr[i]] = true;
}
return result;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Test1 |
| ready |
Test2 |
| ready |
Test3 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.