MCPcopy Create free account
hub / github.com/ActiveState/code / count_cmps

Function count_cmps

recipes/Python/577573_Compare_algorithms/recipe-577573.py:16–24  ·  view source on GitHub ↗

Count comparisons in a call to f(k, data)

(f, data, k)

Source from the content-addressed store, hash-verified

14 return int.__le__(self, other)
15
16def count_cmps(f, data, k):
17 'Count comparisons in a call to f(k, data)'
18 global cmps
19 data = data[:]
20 shuffle(data)
21 cmps = 0
22 result = f(k, data)
23 assert result[:10] == list(range(10))
24 return cmps
25
26# -------- variants of nsmallest -------
27

Callers 1

recipe-577573.pyFile · 0.85

Calls 4

listClass · 0.85
rangeFunction · 0.85
shuffleFunction · 0.50
fFunction · 0.50

Tested by

no test coverage detected