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 tests whether creating an array of one member by testing first using .isArray() and then wrapping the member in an array is faster or slower than creating a single member array using the spread command on a Set object.
<script>
function createArray1(item1) {
let itemArray1 = Array.isArray(item1) ? item1 : [item1];
console.log(itemArray1);
}
function createArray2(item2) {
let itemArray2 = new Array(...new Set(item2));
console.log(itemArray2);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Build Array by checking |
| ready |
Build Array from Set |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.