1
0
mirror of https://github.com/nolanlawson/pinafore synced 2025-02-02 22:57:36 +01:00

27 lines
591 B
JavaScript
Raw Normal View History

2018-02-21 17:52:33 -08:00
import { thunk } from './thunk'
2018-01-17 00:59:15 -08:00
2018-02-21 17:52:33 -08:00
// Lazily invoke because URLSearchParams isn't supported in Edge 16,
// so we need the polyfill.
const enabled = thunk(() => process.browser &&
2018-02-10 11:36:31 -08:00
performance.mark &&
2018-02-21 17:52:33 -08:00
(
process.env.NODE_ENV !== 'production' ||
new URLSearchParams(location.search).get('marks') === 'true'
)
)
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-02-21 17:52:33 -08:00
if (enabled()) {
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-02-21 17:52:33 -08:00
if (enabled()) {
perf.mark(`end ${name}`)
perf.measure(name, `start ${name}`, `end ${name}`)
}
2018-02-21 17:57:49 -08:00
}