MCPcopy Create free account
hub / github.com/subquery/subql / profilerWrap

Function profilerWrap

packages/node-core/src/profiler.ts:56–75  ·  view source on GitHub ↗
(method: T, target: any, name: string)

Source from the content-addressed store, hash-verified

54
55export const profilerWrap =
56 <T extends AnyFn>(method: T, target: any, name: string) =>
57 (...args: Parameters<T>): ReturnType<T> => {
58 const start = performance.now();
59 const res = method(...args);
60 if (isPromise(res)) {
61 res.then(
62 (_: any) => {
63 printCost(start, performance.now(), target, name);
64 return _;
65 },
66 (err: any) => {
67 printCost(start, performance.now(), target, name);
68 throw err;
69 }
70 );
71 } else {
72 printCost(start, performance.now(), target, name);
73 }
74 return res;
75 };

Callers 3

indexDataFunction · 0.90
constructorMethod · 0.90
updateBlockFetchingMethod · 0.90

Calls 2

isPromiseFunction · 0.85
printCostFunction · 0.85

Tested by

no test coverage detected