mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 03:12:35 +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 {
|
||||
duration,
|
||||
detail: {memoryUsage},
|
||||
} = performance.measure(label);
|
||||
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 {
|
||||
detail: {memoryUsage},
|
||||
} = startMark;
|
||||
printPerfLog({
|
||||
label: applyParentPrefix(label),
|
||||
duration,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue