Created
December 15, 2018 16:20
-
-
Save clarencetw/8b7a2f49f533a43539eecd276578c8a8 to your computer and use it in GitHub Desktop.
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
const { performance: perf } = require('perf_hooks'); | |
function test() { | |
}; | |
let code = { | |
domain: 'abcdef.com', | |
account: 'ab@abc.com' | |
} | |
let len = 10; | |
let account = new Array(len + 1).join( code.account ); | |
code.account = account; | |
let count = 100; | |
const bucket = []; | |
for(var i = 0; i<count; i++) { | |
perf.mark('A'); | |
test() | |
perf.mark('B'); | |
perf.measure('A to B', 'A', 'B'); | |
const measure = perf.getEntriesByName('A to B'); | |
bucket.push(measure[0].duration); | |
perf.clearMarks(['A to B', 'A', 'B']) | |
perf.clearMeasures() | |
} | |
console.log("MAX: ", Math.max(...bucket)); | |
console.log("AVG: ", bucket.reduce((a,b) => a + b, 0) / bucket.length); | |
console.log("MIN: ", Math.min(...bucket)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment