MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / measure

Function measure

packages/web/src/lib/utils.ts:556–574  ·  view source on GitHub ↗
(cb: () => Promise<T>, measureName: string, outputLog: boolean = true)

Source from the content-addressed store, hash-verified

554}
555
556export const measure = async <T>(cb: () => Promise<T>, measureName: string, outputLog: boolean = true) => {
557 const startMark = `${measureName}.start`;
558 const endMark = `${measureName}.end`;
559
560 performance.mark(startMark);
561 const data = await cb();
562 performance.mark(endMark);
563
564 const measure = performance.measure(measureName, startMark, endMark);
565 const durationMs = measure.duration;
566 if (outputLog) {
567 console.debug(`[${measureName}] took ${durationMs}ms`);
568 }
569
570 return {
571 data,
572 durationMs
573 }
574}
575
576/**
577 * Unwraps a promise that could return a ServiceError, throwing an error if it does.

Callers 5

ChatLandingPageFunction · 0.90
FileTreePanelFunction · 0.90
ExploreMenuFunction · 0.90
useHoveredOverSymbolInfoFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected