MCPcopy Create free account
hub / github.com/code-pushup/cli / measureAsync

Method measureAsync

packages/utils/src/lib/profiler/profiler.ts:220–239  ·  view source on GitHub ↗

* 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>,
  )

Source from the content-addressed store, hash-verified

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}

Calls 1

isEnabledMethod · 0.95

Tested by

no test coverage detected