MCPcopy
hub / github.com/monkeytypegame/monkeytype / logTiming

Function logTiming

frontend/src/ts/utils/debug.ts:35–71  ·  view source on GitHub ↗
(start: number, funcName: string)

Source from the content-addressed store, hash-verified

33}
34
35function logTiming(start: number, funcName: string): void {
36 const end = performance.now();
37 const time = end - start;
38
39 if (!timings.has(funcName)) {
40 timings.set(funcName, []);
41 }
42
43 const arr = timings.get(funcName) as number[];
44 arr.push(time);
45
46 console.log(`${funcName} took ${roundTo2(time)} ms`);
47 console.log(funcName, {
48 average: `${roundTo2(mean(arr))} ms`,
49 stdDev: `${roundTo2(stdDev(arr))} ms`,
50 min: `${roundTo2(Math.min(...arr))} ms`,
51 max: `${roundTo2(Math.max(...arr))} ms`,
52 count: arr.length,
53 });
54 const endOverhead = performance.now();
55 console.timeStamp(
56 `#${arr.length} ${funcName}`,
57 //@ts-expect-error chrome api thingy
58 start,
59 end,
60 funcName,
61 "monkeytype",
62 );
63 console.timeStamp(
64 `#${arr.length} profiling overhead`,
65 //@ts-expect-error chrome api thingy
66 end,
67 endOverhead,
68 funcName,
69 "monkeytype",
70 );
71}

Callers 1

Calls 6

roundTo2Function · 0.90
meanFunction · 0.90
stdDevFunction · 0.90
setMethod · 0.80
pushMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected