chore: add benchmark analysis scripts
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import csv
|
||||
import sys
|
||||
|
||||
def analyze(filename, label):
|
||||
durations = []
|
||||
lengths = []
|
||||
nodes = []
|
||||
failed = 0
|
||||
total = 0
|
||||
stutters = 0
|
||||
try:
|
||||
with open(filename, 'r') as f:
|
||||
reader = csv.reader(f)
|
||||
next(reader)
|
||||
for row in reader:
|
||||
if not row or row[0].startswith('#'):
|
||||
if 'total_paths' in ','.join(row) if row else '':
|
||||
continue
|
||||
continue
|
||||
total += 1
|
||||
try:
|
||||
d = int(row[1])
|
||||
durations.append(d)
|
||||
lengths.append(int(row[2]))
|
||||
nodes.append(int(row[3]))
|
||||
if d > 1000: stutters += 1
|
||||
except:
|
||||
pass
|
||||
|
||||
if not durations:
|
||||
return
|
||||
durations.sort()
|
||||
lengths.sort()
|
||||
nodes.sort()
|
||||
|
||||
p50 = durations[len(durations)//2]
|
||||
p90 = durations[int(len(durations)*0.90)]
|
||||
p99 = durations[int(len(durations)*0.99)]
|
||||
max_d = durations[-1]
|
||||
|
||||
avg_nodes = sum(nodes) / len(nodes) if nodes else 0
|
||||
avg_len = sum(lengths) / len(lengths) if lengths else 0
|
||||
|
||||
print(f"\n=== {label} ===")
|
||||
print(f"Total paths: {total}")
|
||||
print(f"P50: {p50}µs | P90: {p90}µs | P99: {p99}µs | Max: {max_d}µs")
|
||||
print(f"Stutters (>1ms): {stutters} ({100*stutters/total:.2f}%)")
|
||||
print(f"Avg nodes: {avg_nodes:.1f} | Avg length: {avg_len:.1f}")
|
||||
print(f"Median length: {lengths[len(lengths)//2]}")
|
||||
return durations, lengths, nodes, stutters, total
|
||||
except Exception as e:
|
||||
print(f"Error reading {filename}: {e}")
|
||||
return None
|
||||
|
||||
base = analyze("/home/popertots/bench/pathfinding_benchmark_baseline_release.csv", "ORIGINAL BASELINE (>6 months ago, 5x5 map)")
|
||||
cur = analyze("pathfinding_benchmark_current.csv", "CURRENT (15x15 map, after all fixes)")
|
||||
|
||||
if base and cur:
|
||||
print("\n=== COMPARISON ===")
|
||||
b_dur, b_len, b_nodes, b_stut, b_tot = base
|
||||
c_dur, c_len, c_nodes, c_stut, c_tot = cur
|
||||
|
||||
p50_imp = (b_dur[len(b_dur)//2] - c_dur[len(c_dur)//2]) / b_dur[len(b_dur)//2] * 100
|
||||
p99_imp = (b_dur[int(len(b_dur)*0.99)] - c_dur[int(len(c_dur)*0.99)]) / b_dur[int(len(b_dur)*0.99)] * 100
|
||||
stutter_imp = (b_stut - c_stut) / b_stut * 100 if b_stut > 0 else 0
|
||||
|
||||
print(f"P50 improvement: {p50_imp:+.1f}%")
|
||||
print(f"P99 improvement: {p99_imp:+.1f}%")
|
||||
print(f"Stutter reduction: {stutter_imp:+.1f}%")
|
||||
print(f"Map size: 5x5 -> 15x15 (9x larger area)")
|
||||
Reference in New Issue
Block a user