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

Method measure

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

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

Source from the content-addressed store, hash-verified

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.

Calls 1

isEnabledMethod · 0.95

Tested by

no test coverage detected