fedilove-ui/routes/_utils/marks.js

20 lines
411 B
JavaScript

const enabled = process.browser && performance.mark && (
process.env.NODE_ENV !== 'production' ||
location.search.includes('marks=true')
)
const perf = process.browser && performance
export function mark (name) {
if (enabled) {
perf.mark(`start ${name}`)
}
}
export function stop (name) {
if (enabled) {
perf.mark(`end ${name}`)
perf.measure(name, `start ${name}`, `end ${name}`)
}
}