Files
30-seconds-of-code/test/mostPerformant/mostPerformant.js
Angelos Chalaris a78f5db260 Test migration to jest by hand
Apparently using regular expressions is way easier.
2018-06-18 15:15:56 +03:00

9 lines
274 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;