mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-28 04:03:05 +00:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import {
|
|
consumePersistedPerfDiagnosticReports,
|
|
getPerfDiagnosticsSnapshot,
|
|
isPerfDiagnosticsEnabled,
|
|
peekPersistedPerfDiagnosticReports,
|
|
} from "./engine";
|
|
|
|
export function installPerfDiagnosticsDebugTools(): () => void {
|
|
if (!isPerfDiagnosticsEnabled()) {
|
|
return () => {};
|
|
}
|
|
|
|
(
|
|
globalThis as {
|
|
__PASEO_PERF_DIAGNOSTICS_DEBUG__?: {
|
|
snapshot: (limit?: number) => ReturnType<typeof getPerfDiagnosticsSnapshot>;
|
|
consumeReports: () => Promise<
|
|
Awaited<ReturnType<typeof consumePersistedPerfDiagnosticReports>>
|
|
>;
|
|
peekReports: () => Promise<
|
|
Awaited<ReturnType<typeof peekPersistedPerfDiagnosticReports>>
|
|
>;
|
|
};
|
|
}
|
|
).__PASEO_PERF_DIAGNOSTICS_DEBUG__ = {
|
|
snapshot: (limit?: number) => getPerfDiagnosticsSnapshot(limit ?? 120),
|
|
consumeReports: () => consumePersistedPerfDiagnosticReports(),
|
|
peekReports: () => peekPersistedPerfDiagnosticReports(),
|
|
};
|
|
|
|
return () => {
|
|
(
|
|
globalThis as {
|
|
__PASEO_PERF_DIAGNOSTICS_DEBUG__?: unknown;
|
|
}
|
|
).__PASEO_PERF_DIAGNOSTICS_DEBUG__ = undefined;
|
|
};
|
|
}
|