pinafore/routes/_utils/marks.js

20 lines
411 B
JavaScript
Raw Normal View History

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