Files
shockbot/utils/timer.ts
T
Colin McDonnell 4826e9acb1 Clean up logs
2025-12-17 12:43:08 -08:00

21 lines
495 B
TypeScript

import { log } from "./cli.ts";
export class Timer {
private initialTimestamp: number;
private lastCheckpointTimestamp: number | null = null;
constructor() {
this.initialTimestamp = Date.now();
}
checkpoint(name: string): void {
const now = Date.now();
const duration = this.lastCheckpointTimestamp
? now - this.lastCheckpointTimestamp
: now - this.initialTimestamp;
log.debug(`» ${name}: ${duration}ms`);
this.lastCheckpointTimestamp = now;
}
}