1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Paired probes of the actual relay's 100-DID collection page method."""
import csv
from pathlib import Path
import subprocess
import sys
binary, legacy, grouped, count, output = sys.argv[1:]
fields = ['variant', 'trial', 'returned_dids', 'elapsed_ns', 'p50_ns', 'p95_ns', 'p99_ns', 'digest']
with Path(output).open('w') as file:
writer = csv.writer(file)
writer.writerow(fields)
for trial in range(5):
results = []
for variant in (['legacy', 'grouped'] if trial % 2 == 0 else ['grouped', 'legacy']):
database = legacy if variant == 'legacy' else grouped
data = subprocess.check_output([binary, database, 'pages', '0', count, '0'],
stderr=subprocess.STDOUT, text=True)
row = next(csv.reader([next(s for s in data.splitlines() if s.startswith('pages,'))]))
writer.writerow([variant, trial, *row[1:]])
file.flush()
results.append((row[1], row[-1]))
assert results[0] == results[1], results
print('five paired collection-page trials passed')