(stage: string, ref: UnresolvedRef, fn: () => T)
| 2194 | process.env.CODEGRAPH_RESOLVE_PROFILE === '2' ? new Map() : null; |
| 2195 | |
| 2196 | function nmTimedT<T>(stage: string, ref: UnresolvedRef, fn: () => T): T { |
| 2197 | if (!NM_PROFILE) return fn(); |
| 2198 | const t0 = process.hrtime.bigint(); |
| 2199 | const r = fn(); |
| 2200 | const dt = process.hrtime.bigint() - t0; |
| 2201 | const key = `nm:${stage}|${ref.referenceKind}|${r ? 'hit' : 'miss'}`; |
| 2202 | const slot = NM_PROFILE.get(key); |
| 2203 | if (slot) { |
| 2204 | slot.n++; |
| 2205 | slot.ns += dt; |
| 2206 | } else { |
| 2207 | NM_PROFILE.set(key, { n: 1, ns: dt }); |
| 2208 | } |
| 2209 | return r; |
| 2210 | } |
| 2211 | |
| 2212 | function nmTimed(stage: string, ref: UnresolvedRef, fn: () => ResolvedRef | null): ResolvedRef | null { |
| 2213 | return nmTimedT(stage, ref, fn); |
no test coverage detected