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
const generateShuffledArray = (lim) => {
// Generate an array of numbers from 0 to lim-1
let numbers = Array.from({length: lim}, (_, index) => index);
// Shuffle the numbers array using the Fisher-Yates (Durstenfeld) shuffle algorithm
for (let i = numbers.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[numbers[i], numbers[j]] = [numbers[j], numbers[i]];
}
// Pair each 'line_n' with a unique shuffled number
let resultArray = numbers.map((num, index) => [`line_${index + 1}`, num.toString()]);
return resultArray;
}
const lim = 10000; // Set the limit, adjust as necessary
const my_array = generateShuffledArray(lim);
console.log(my_array);
Ready to run.
Test | Ops/sec | |
---|---|---|
Sort plus map |
| ready |
Insertion into existing array |
| ready |
Reduce to array |
| ready |
Object.values of fromEntries |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.