@docusaurus/logger
Advanced tools
Comparing version 3.7.0-canary-6193 to 3.7.0-canary-6194
@@ -74,5 +74,14 @@ "use strict"; | ||
}); | ||
const readMark = (label) => { | ||
const startMark = performance.getEntriesByName(label, 'mark')?.[0]; | ||
if (!startMark) { | ||
throw new Error(`No performance start mark for label=${label}`); | ||
} | ||
performance.clearMarks(label); | ||
return startMark; | ||
}; | ||
const end = (label) => { | ||
const { duration, detail: { memoryUsage }, } = performance.measure(label); | ||
performance.clearMarks(label); | ||
const startMark = readMark(label); | ||
const duration = performance.now() - startMark.startTime; | ||
const { detail: { memoryUsage }, } = startMark; | ||
printPerfLog({ | ||
@@ -79,0 +88,0 @@ label: applyParentPrefix(label), |
{ | ||
"name": "@docusaurus/logger", | ||
"version": "3.7.0-canary-6193", | ||
"version": "3.7.0-canary-6194", | ||
"description": "An encapsulated logger for semantically formatting console messages.", | ||
@@ -32,3 +32,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "9abfde23486f800556b7ef9e75a88e7e7d089eb8" | ||
"gitHead": "c0f66b14b97127d64562c4ab28b0a911fdedbe0f" | ||
} |
@@ -117,8 +117,20 @@ /** | ||
const readMark = (label: string) => { | ||
const startMark = performance.getEntriesByName( | ||
label, | ||
'mark', | ||
)?.[0] as PerformanceMark; | ||
if (!startMark) { | ||
throw new Error(`No performance start mark for label=${label}`); | ||
} | ||
performance.clearMarks(label); | ||
return startMark; | ||
}; | ||
const end: PerfLoggerAPI['end'] = (label) => { | ||
const startMark = readMark(label); | ||
const duration = performance.now() - startMark.startTime; | ||
const { | ||
duration, | ||
detail: {memoryUsage}, | ||
} = performance.measure(label); | ||
performance.clearMarks(label); | ||
} = startMark; | ||
printPerfLog({ | ||
@@ -125,0 +137,0 @@ label: applyParentPrefix(label), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
139781
847