Files
30-seconds-of-code/test/mostPerformant/mostPerformant.js
2018-06-18 19:07:48 +03:00

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;