| 1 | // Alchemy modifications are licensed under Apache-2.0. |
| 2 | // This file includes third-party code; see /THIRD_PARTY_LICENSES.md. |
| 3 | import type { UnsafePerformanceTimer } from "./types.ts"; |
| 4 | |
| 5 | export class PerformanceTimer { |
| 6 | private performanceTimer; |
| 7 | |
| 8 | constructor(performanceTimer?: UnsafePerformanceTimer) { |
| 9 | this.performanceTimer = performanceTimer; |
| 10 | } |
| 11 | |
| 12 | now() { |
| 13 | if (this.performanceTimer) { |
| 14 | return this.performanceTimer.timeOrigin + this.performanceTimer.now(); |
| 15 | } |
| 16 | return Date.now(); |
| 17 | } |
| 18 | } |