2018-01-17 08:59:15 +00:00
|
|
|
import noop from 'lodash/noop'
|
|
|
|
|
2018-01-31 16:40:37 +00:00
|
|
|
const enableMarks = process.browser &&
|
2018-02-10 19:36:31 +00:00
|
|
|
performance.mark &&
|
2018-01-31 16:40:37 +00:00
|
|
|
(process.env.NODE_ENV !== 'production' ||
|
|
|
|
new URLSearchParams(location.search).get('marks') === 'true')
|
2018-01-17 08:59:15 +00:00
|
|
|
|
2018-02-10 19:36:31 +00:00
|
|
|
const perf = process.browser && performance
|
|
|
|
|
|
|
|
function doMark(name) {
|
|
|
|
perf.mark(`start ${name}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
function doStop(name) {
|
|
|
|
perf.mark(`end ${name}`)
|
|
|
|
perf.measure(name, `start ${name}`, `end ${name}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
const mark = enableMarks ? doMark : noop
|
|
|
|
const stop = enableMarks ? doStop : noop
|
2018-01-17 08:59:15 +00:00
|
|
|
|
|
|
|
export {
|
|
|
|
mark,
|
|
|
|
stop
|
2018-02-09 06:29:29 +00:00
|
|
|
}
|