mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-06 12:52:31 +02:00
fix: perflogger mark detail bug (#10818)
This commit is contained in:
parent
0df69844b6
commit
431526ecbc
1 changed files with 17 additions and 5 deletions
|
@ -114,12 +114,24 @@ function createPerfLogger(): PerfLoggerAPI {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const end: PerfLoggerAPI['end'] = (label) => {
|
const readMark = (label: string) => {
|
||||||
const {
|
const startMark = performance.getEntriesByName(
|
||||||
duration,
|
label,
|
||||||
detail: {memoryUsage},
|
'mark',
|
||||||
} = performance.measure(label);
|
)?.[0] as PerformanceMark;
|
||||||
|
if (!startMark) {
|
||||||
|
throw new Error(`No performance start mark for label=${label}`);
|
||||||
|
}
|
||||||
performance.clearMarks(label);
|
performance.clearMarks(label);
|
||||||
|
return startMark;
|
||||||
|
};
|
||||||
|
|
||||||
|
const end: PerfLoggerAPI['end'] = (label) => {
|
||||||
|
const startMark = readMark(label);
|
||||||
|
const duration = performance.now() - startMark.startTime;
|
||||||
|
const {
|
||||||
|
detail: {memoryUsage},
|
||||||
|
} = startMark;
|
||||||
printPerfLog({
|
printPerfLog({
|
||||||
label: applyParentPrefix(label),
|
label: applyParentPrefix(label),
|
||||||
duration,
|
duration,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue