Shuffle
Shuffle random integers
by evgkch
JavaScript
const createArray = (length) => Array.from( {length: length}, (v, k) => k );
const shuffle = (array) => array.sort( (a, b) => Math.random() - 0.5 );
const test = (n) => {
let start = new Date().getTime();
shuffle(createArray(n));
let finish = new Date().getTime();
return console.log(`Lead time: ${Math.round(finish - start)} msec`)
}
test(10000)
test(100000)
test(1000000)