Last active
July 20, 2018 05:02
-
-
Save koba04/2691b22f9204956727f27be829684ac9 to your computer and use it in GitHub Desktop.
Web Perf snippets
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
var resources = performance.getEntriesByType('resource'); | |
resources.forEach(resource => { | |
console.log( | |
`Name: ${resource.name}\n`, | |
`Entry Type: ${resource.entryType}\n`, | |
`Start Time: ${resource.startTime}\n`, | |
`Duration: ${resource.duration}\n`, | |
`Redirect: ${resource.redirectEnd - resource.redirectStart}\n`, | |
`DNS: ${resource.domainLookupEnd - resource.domainLookupStart}\n`, | |
`TCP: ${resource.connectEnd - resource.connectStart}\n`, | |
`Request: ${resource.responseStart - resource.requestStart}\n`, | |
`Response: ${resource.responseEnd - resource.responseStart}\n` | |
); | |
}); |
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
performance.mark('start'); | |
setTimeout(() => { | |
performance.mark('end'); | |
performance.measure('measure-start-end', 'start', 'end'); | |
console.log(performance.getEntriesByType('mark')); | |
console.log(performance.getEntriesByType('measure')); | |
// or | |
console.log(performance.getEntriesByName('start')); | |
console.log(performance.getEntriesByName('measure-start-end')); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment