pre-bemis
This commit is contained in:
18
lib/perf/serverTiming.ts
Normal file
18
lib/perf/serverTiming.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { performance } from "perf_hooks";
|
||||
|
||||
export const PERF_LOGS_ENABLED = process.env.PERF_LOGS === "1";
|
||||
|
||||
export function nowMs() {
|
||||
return performance.now();
|
||||
}
|
||||
|
||||
export function elapsedMs(startMs: number) {
|
||||
return Math.round((performance.now() - startMs) * 100) / 100;
|
||||
}
|
||||
|
||||
export function formatServerTiming(entries: Record<string, number>) {
|
||||
return Object.entries(entries)
|
||||
.filter(([, value]) => Number.isFinite(value))
|
||||
.map(([name, value]) => `${name};dur=${value.toFixed(1)}`)
|
||||
.join(", ");
|
||||
}
|
||||
Reference in New Issue
Block a user