MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / once

Function once

benchmarks/big-decimal/ops-bench.py:49–59  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

47NA = ['round', 'normalize', 'cmp'] # no faithful mpmath analog
48
49def once(fn):
50 for i in range(50):
51 fn(i & MASK) # warm
52 n = 0
53 t0 = time.perf_counter()
54 while True:
55 fn(n & MASK)
56 n += 1
57 if (n & 31) == 0 and time.perf_counter() - t0 >= budget_s:
58 break
59 return (time.perf_counter() - t0) / n * 1e9 # ns/op
60
61rows = []
62for op, fn in OPS.items():

Callers 1

ops-bench.pyFile · 0.70

Calls 2

rangeFunction · 0.85
fnFunction · 0.85

Tested by

no test coverage detected