(fn: () => void, iterations: number)
| 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; |
no outgoing calls
no test coverage detected