Add input handling

This commit is contained in:
schmelczerandras 2020-07-18 22:02:09 +02:00
parent 29c6b14440
commit d5be727040
36 changed files with 417 additions and 113 deletions

View file

@ -0,0 +1,22 @@
export const TimeIt = (func, interval = 60) => {
let i = 0;
let values = [];
return () => {
const start = performance.now();
func();
const end = performance.now();
values.push(end - start);
if (++i % interval == 0) {
values.sort();
console.log(
`${func.name}\n\tMax ${values[values.length - 1].toFixed(
2
)} ms\n\tMedian ${values[Math.floor(values.length / 2)].toFixed(2)} ms`
);
values = [];
}
};
};