Skip to content

Instantly share code, notes, and snippets.

@lukechilds

lukechilds/README.md

Created Apr 11, 2017
Embed
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).

Usage

time = fn=>{let t=()=>performance.now(),s=t();fn();return t()-s}
time(() => document.querySelectorAll('span'))
// 0.18499999959021807
time(() => document.getElementsByTagName('span'))
// 0.04000000050291419
fn=>{let t=()=>performance.now(),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.