(name: string)
| 54 | } |
| 55 | |
| 56 | export function stop(name: string): TimerInfo { |
| 57 | const info = timers[name]; |
| 58 | |
| 59 | if (!info) { |
| 60 | throw new Error(`No timer started: ${name}`); |
| 61 | } |
| 62 | |
| 63 | if (info.runCount) { |
| 64 | info.runCount--; |
| 65 | if (info.runCount) { |
| 66 | info.count++; |
| 67 | } else { |
| 68 | info.lastTime = time() - info.currentStart; |
| 69 | info.totalTime += info.lastTime; |
| 70 | info.count++; |
| 71 | info.currentStart = 0; |
| 72 | } |
| 73 | } else { |
| 74 | throw new Error(`Timer ${name} paused more times than started.`); |
| 75 | } |
| 76 | |
| 77 | return info; |
| 78 | } |
| 79 | |
| 80 | export function timer(name: string): TimerInfo { |
| 81 | return timers[name]; |
no test coverage detected