mirror of
https://github.com/ZetaKebab/quartz.git
synced 2025-06-22 08:44:36 +00:00
plugin integration round 2
This commit is contained in:
19
quartz/perf.ts
Normal file
19
quartz/perf.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import chalk from 'chalk'
|
||||
import pretty from 'pretty-time'
|
||||
|
||||
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 chalk.yellow(pretty(process.hrtime(this.evts[evtName ?? 'start'])))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user