summary refs log tree commit diff stats
path: root/test4.py
blob: b2390a036b1229ea4a19e55c1f9a0061dfe790f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
generated by cgit-pink 1.4.1-2-gfad0 (git 2.36.2.497.gbbea4dcf42) at 2024-12-17 16:19:28 +0000
 


"n">v in d.copy().items():
			if v == 0: del d[k]
		return d

	def c(d):
		for k in tuple(d.keys()):
			if d[k] == 0: del d[k]
		return d

	def d(d):
		for k, v in tuple(d.items()):
			if v == 0: del d[k]
		return d


basedict = {}
for i in range(200):
	basedict[i] = random.randint(0, 1)

expected = DelValue.a(basedict.copy())

for algo in ['a', 'b', 'c', 'd']:
	copy = basedict.copy()
	t = time.time()
	for i in range(100):
		assert DelValue.__dict__[algo](copy) == expected
	print("algorithm %s: %f" % (algo, time.time() - t))

# c it is, although b is faster with smaller dictionaries