fix(kit): provide name to `performance.mark()` (#19687)

This commit is contained in:
Daniel Roe 2023-03-15 11:26:01 +00:00 committed by GitHub
parent f9d7e1c900
commit 886cca19ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -68,9 +68,10 @@ export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: Mo
}
// Call setup
const mark = performance.mark()
const key = `nuxt:module:${uniqueKey || (Math.round(Math.random() * 10000))}`
const mark = performance.mark(key)
const res = await definition.setup?.call(null as any, _options, nuxt) ?? {}
const perf = performance.measure(`nuxt:module:${uniqueKey || (Math.round(Math.random() * 10000))}`, mark.name)
const perf = performance.measure(key, mark.name)
const setupTime = Math.round((perf.duration * 100)) / 100
// Measure setup time