mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 14:58:44 +01:00
Some checks failed
Build and Test / build-and-test (ubuntu-latest) (push) Has been skipped
Build and Test / publish-tag (push) Has been skipped
Build and Test / build-and-test (macos-latest) (push) Has been cancelled
Build and Test / build-and-test (windows-latest) (push) Has been cancelled
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
20 lines
415 B
TypeScript
20 lines
415 B
TypeScript
import pretty from "pretty-time"
|
|
import { styleText } from "util"
|
|
|
|
export class PerfTimer {
|
|
evts: { [key: string]: [number, number] }
|
|
|
|
constructor() {
|
|
this.evts = {}
|
|
this.addEvent("start")
|
|
}
|
|
|
|
addEvent(evtName: string) {
|
|
this.evts[evtName] = process.hrtime()
|
|
}
|
|
|
|
timeSince(evtName?: string): string {
|
|
return styleText("yellow", pretty(process.hrtime(this.evts[evtName ?? "start"])))
|
|
}
|
|
}
|