fedilove-ui/routes/_utils/marks.js

20 lines
411 B
JavaScript
Raw Normal View History

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