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

26 lines
521 B
JavaScript
Raw Normal View History

2018-01-17 00:59:15 -08:00
import noop from 'lodash/noop'
2018-01-31 08:40:37 -08:00
const enableMarks = process.browser &&
2018-02-10 11:36:31 -08:00
performance.mark &&
2018-01-31 08:40:37 -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-11 09:37:13 -08:00
function doMark (name) {
2018-02-10 11:36:31 -08:00
perf.mark(`start ${name}`)
}
2018-02-11 09:37:13 -08:00
function doStop (name) {
2018-02-10 11:36:31 -08:00
perf.mark(`end ${name}`)
perf.measure(name, `start ${name}`, `end ${name}`)
}
const mark = enableMarks ? doMark : noop
const stop = enableMarks ? doStop : noop
2018-01-17 00:59:15 -08:00
export {
mark,
stop
2018-02-08 22:29:29 -08:00
}