9 lines
277 B
JavaScript
9 lines
277 B
JavaScript
const mostPerformant = (fns, iterations = 10000) => {
|
|
const times = fns.map(fn => {
|
|
const before = performance.now();
|
|
for (let i = 0; i < iterations; i++) fn();
|
|
return performance.now() - before;
|
|
});
|
|
return times.indexOf(Math.min(...times));
|
|
};
|
|
module.exports = mostPerformant; |