Skip to content

Instantly share code, notes, and snippets.



Created Apr 11, 2017
What would you like to do?
JavaScript performance testing accurate to 5 microseconds in 59 bytes

Performance testing accurate to 5 microseconds in 57 bytes

Test JavaScript methods against each other accurate to 5 microseconds (five thousandths of a millisecond).


time = fn=>{let t=()=>,s=t();fn();return t()-s}
time(() => document.querySelectorAll('span'))
// 0.18499999959021807
time(() => document.getElementsByTagName('span'))
// 0.04000000050291419
fn=>{let t=()=>,s=t();fn();return t()-s}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.