| 1 | import process from 'node:process' |
| 2 | |
| 3 | export default class Stats { |
| 4 | declare startTimes: Record<string, [number, number]>; |
| 5 | [label: string]: unknown; |
| 6 | |
| 7 | constructor() { |
| 8 | Object.defineProperties(this, { |
| 9 | startTimes: { value: {} }, |
| 10 | }) |
| 11 | } |
| 12 | |
| 13 | time(label: string): void { |
| 14 | this.startTimes[label] = process.hrtime() |
| 15 | } |
| 16 | |
| 17 | timeEnd(label: string): void { |
| 18 | const elapsed = process.hrtime(this.startTimes[label]) |
| 19 | |
| 20 | if (!this[label]) |
| 21 | this[label] = 0 |
| 22 | this[label] = (this[label] as number) + elapsed[0] * 1e3 + elapsed[1] * 1e-6 |
| 23 | } |
| 24 | } |
nothing calls this directly
no outgoing calls
no test coverage detected