* Measures the execution time of an asynchronous operation. * * For synchronous operations, use the measure method. * * Creates performance start/end marks and a final measure. * All entries have Chrome DevTools Extensibility API payload and are visualized under custom tracks.
(
event: string,
work: () => Promise<R>,
options?: MeasureOptions<R>,
)
| 218 | * |
| 219 | */ |
| 220 | async measureAsync<R>( |
| 221 | event: string, |
| 222 | work: () => Promise<R>, |
| 223 | options?: MeasureOptions<R>, |
| 224 | ): Promise<R> { |
| 225 | if (!this.isEnabled()) { |
| 226 | return await work(); |
| 227 | } |
| 228 | |
| 229 | const { start, success, error } = this.#ctxOf(event, options); |
| 230 | start(); |
| 231 | try { |
| 232 | const r = await work(); |
| 233 | success(r); |
| 234 | return r; |
| 235 | } catch (error_) { |
| 236 | error(error_); |
| 237 | throw error_; |
| 238 | } |
| 239 | } |
| 240 | } |
no test coverage detected