1
0
mirror of https://github.com/nolanlawson/pinafore synced 2025-02-02 14:56:48 +01:00

20 lines
411 B
JavaScript
Raw Normal View History

2018-03-09 00:08:23 -08:00
const enabled = process.browser && performance.mark && (
process.env.NODE_ENV !== 'production' ||
location.search.includes('marks=true')
2018-02-21 17:52:33 -08:00
)
2018-01-17 00:59:15 -08:00
2018-02-10 11:36:31 -08:00
const perf = process.browser && performance
2018-02-21 17:57:49 -08:00
export function mark (name) {
2018-03-09 00:08:23 -08:00
if (enabled) {
2018-02-21 17:52:33 -08:00
perf.mark(`start ${name}`)
}
2018-02-10 11:36:31 -08:00
}
2018-02-21 17:57:49 -08:00
export function stop (name) {
2018-03-09 00:08:23 -08:00
if (enabled) {
2018-02-21 17:52:33 -08:00
perf.mark(`end ${name}`)
perf.measure(name, `start ${name}`, `end ${name}`)
}
2018-02-21 17:57:49 -08:00
}