blob: 51329a7f54c9969ef497b052c431ea12b1253f15 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/usr/bin/env python3
"""Pair up per-problem achieved-depth (final iterated depth reached before
the node-count budget ran out) from two sn=N ECM stdout logs (same input
file, same order) and report win/loss/tie counts plus median depth delta.
"""
import re
import statistics
import sys
TELL_RE = re.compile(r"tellothers d(\d+),")
def parse(path):
"""Return list of achieved-depth ints, one per completed problem, in order."""
depths = []
with open(path) as f:
for line in f:
m = TELL_RE.search(line)
if m:
depths.append(int(m.group(1)))
return depths
def main():
base_path, cand_path = sys.argv[1], sys.argv[2]
base = parse(base_path)
cand = parse(cand_path)
n = min(len(base), len(cand))
base, cand = base[:n], cand[:n]
deltas = [c - b for b, c in zip(base, cand)]
wins = sum(1 for d in deltas if d > 0)
losses = sum(1 for d in deltas if d < 0)
ties = sum(1 for d in deltas if d == 0)
print(f"Paired problems: {n}")
print(f" candidate deeper: {wins}")
print(f" candidate shallower: {losses}")
print(f" tied depth: {ties}")
print(f" median depth delta (candidate - baseline): {statistics.median(deltas):+.1f}")
print(f" mean depth delta: {statistics.mean(deltas):+.3f}")
print(f" sum of depth delta: {sum(deltas):+d}")
if __name__ == "__main__":
main()
|