MCPcopy Create free account
hub / github.com/coder/mux / measureAvgTime

Function measureAvgTime

src/node/orpc/authMiddleware.test.ts:39–46  ·  view source on GitHub ↗
(fn: () => void, iterations: number)

Source from the content-addressed store, hash-verified

37 const secret = "a".repeat(256);
38
39 function measureAvgTime(fn: () => void, iterations: number): number {
40 const start = process.hrtime.bigint();
41 for (let i = 0; i < iterations; i++) {
42 fn();
43 }
44 const end = process.hrtime.bigint();
45 return Number(end - start) / iterations;
46 }
47
48 it("takes similar time for matching vs non-matching strings of same length", () => {
49 const matching = secret;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected