-
-
Save codeNameAtlas/ca9b421daa9786b3835729979abd080a to your computer and use it in GitHub Desktop.
User timing api exercise with chrome
This file contains 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
// set iterations high to measure performance at scale on a simple function | |
let iterations = 1e7; | |
const a = 1; | |
const b = 2; | |
const add = (x, y) => x + y; | |
// start measuring performance | |
performance.mark('start'); | |
// code to measure | |
while (iterations--) { | |
add(a, b); | |
} | |
// end measuring performance | |
performance.mark('end'); | |
performance.measure('My Special Benchmark', 'start', 'end'); | |
const [ measure ] = performance.getEntriesByName('My Special Benchmark'); | |
// output the results to the console | |
console.log(measure); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment