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
This benchmark compares some algorithms to check for the presence of the same elements in two different lists.
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
const makeid = (len = 5) => {
let text = "";
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < len; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
let arr1 = []
let arr2 = []
for (let i = 0; i < 1000; i++) {
arr1.push(makeid())
arr2.push(makeid())
}
// To ensure that both arrays has at least 1 element in common
arr1[arr1.length - 1] = arr2[0]
Ready to run.
Test | Ops/sec | |
---|---|---|
1) Lodash isEmpty and intersection |
| ready |
2) Nested finds |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.