Last active
October 7, 2021 12:39
-
-
Save Mellen/fdbb81ae3d835e848ea3e44fd6261035 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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