-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
32 lines (28 loc) · 979 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from __init__ import generate_id
# Define test
def run_test(seed, iterations=100):
used_ids = []
dupes = []
consecutive_dupes = 0
max_consecutive_dupes = 0
test_num = iterations
for i in range(0, test_num):
id = generate_id(i, seed)
if id in used_ids:
print(f"DUPLICATE: {id}")
print(f"Current atomic_iterator = {i}")
print(id)
dupes.append(id)
consecutive_dupes += 1
else:
print(f"No collision for id {id} at iterator = {i}")
if max_consecutive_dupes < consecutive_dupes:
max_consecutive_dupes = consecutive_dupes
consecutive_dupes = 0
used_ids.append(id)
print(f"Collision on {len(dupes)}/{test_num} ({(len(dupes)/test_num)*100}%)")
print(f"Max consecutive collisions: {max_consecutive_dupes}")
# Run tests
test_seed = "abc123"
run_test(test_seed, 70)
# print(generate_id(14776336, test_seed))