import csv def analyze_tail(filename): durations = [] with open(filename, 'r') as f: reader = csv.reader(f) next(reader) for row in reader: if not row or row[0].startswith('#'): continue try: durations.append(int(row[1])) except: pass durations.sort() n = len(durations) print(f"\n=== TAIL ANALYSIS ({filename}) ===") print(f"Total: {n}") print(f"P50: {durations[n//2]}µs") print(f"P90: {durations[int(n*0.90)]}µs") print(f"P95: {durations[int(n*0.95)]}µs") print(f"P99: {durations[int(n*0.99)]}µs") print(f"P99.5: {durations[int(n*0.995)]}µs") print(f"P99.9: {durations[int(n*0.999)]}µs") print(f"Max: {durations[-1]}µs") # Count stutters for threshold in [500, 1000, 2000, 3000, 5000]: count = sum(1 for d in durations if d > threshold) print(f"Paths > {threshold}µs: {count} ({100*count/n:.2f}%)") # Distribution buckets print("\n=== DISTRIBUTION ===") buckets = [(0, 50), (50, 100), (100, 200), (200, 500), (500, 1000), (1000, 2000), (2000, 5000), (5000, float('inf'))] for lo, hi in buckets: count = sum(1 for d in durations if lo <= d < hi) print(f"{lo}-{hi if hi != float('inf') else '∞'}µs: {count} ({100*count/n:.1f}%)") analyze_tail("/home/popertots/bench/pathfinding_benchmark_baseline_release.csv") analyze_tail("pathfinding_benchmark_current.csv")