measurePerformanceAsync = async (name, fn) => {
performance.mark(`obperf-start-${name}`)
const returnVal = await fn()
performance.mark(`obperf-end-${name}`)
performance.measure(`obperf-${name}`, `obperf-start-${name}`, `obperf-end-${name}`)
const entries = performance.getEntriesByType('measure')
.filter(e => e.name.startsWith('obperf-'))
.map(e => ({ 'Name': e.name.replace('obperf-', ''), 'Duration (ms)': e.duration, 'Measured at (ms after page load)': e.startTime }))
.sort((a, b) => a - b)
mutable performanceEntries = entries
return returnVal
}