* Measures the execution time of a synchronous operation. * * For asynchronous operations, use the measureAsync method. * * Creates performance start/end marks and a final measure. * All entries have Chrome DevTools Extensibility API payload and are visualized under custom tra
(event: string, work: () => R, options?: MeasureOptions<R>)
| 185 | * |
| 186 | */ |
| 187 | measure<R>(event: string, work: () => R, options?: MeasureOptions<R>): R { |
| 188 | if (!this.isEnabled()) { |
| 189 | return work(); |
| 190 | } |
| 191 | |
| 192 | const { start, success, error } = this.#ctxOf(event, options); |
| 193 | start(); |
| 194 | try { |
| 195 | const r = work(); |
| 196 | success(r); |
| 197 | return r; |
| 198 | } catch (error_) { |
| 199 | error(error_); |
| 200 | throw error_; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Measures the execution time of an asynchronous operation. |
no test coverage detected