Skip to content

Instantly share code, notes, and snippets.

@Mellen
Last active October 7, 2021 12:39
Show Gist options
  • Save Mellen/fdbb81ae3d835e848ea3e44fd6261035 to your computer and use it in GitHub Desktop.
Save Mellen/fdbb81ae3d835e848ea3e44fd6261035 to your computer and use it in GitHub Desktop.
function timeit(fn, count, pars)
{
performance.measure('start');
for(let i = 0; i < count; i++)
{
fn(...pars);
}
performance.measure('end');
starts = performance.getEntriesByName('start')
ends = performance.getEntriesByName('end')
performance.clearMeasures('start');
performance.clearMeasures('end');
return ends[ends.length-1].duration - starts[starts.length-1].duration
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment