Restore global onProfilerEvent hook for ts-perf (#52523)

This commit is contained in:
Ron Buckton
2023-01-30 22:23:29 -05:00
committed by GitHub
parent a514c7b15b
commit 1dc5b28b94

View File

@@ -11,6 +11,9 @@ import {
/** Performance measurements for the compiler. */
// NOTE: declared global is injected by ts-perf to monitor profiler marks to generate heap snapshots.
declare let onProfilerEvent: ((eventName: string) => void) | undefined;
let perfHooks: PerformanceHooks | undefined;
// when set, indicates the implementation of `Performance` to use for user timing.
// when unset, indicates user timing is unavailable or disabled.
@@ -74,6 +77,9 @@ export function mark(markName: string) {
counts.set(markName, count + 1);
marks.set(markName, timestamp());
performanceImpl?.mark(markName);
if (typeof onProfilerEvent === "function") {
onProfilerEvent(markName);
}
}
}