Files
dorf/check_nodes.py
T

37 lines
1.4 KiB
Python

import csv
def check_nodes(filename, label):
nodes_list = []
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:
nodes_list.append(int(row[3]))
durations.append(int(row[1]))
except:
pass
print(f"\n=== {label} NODES EXPANDED ===")
print(f"Total paths: {len(nodes_list)}")
# Group by node count
node_buckets = [(0, 0), (1, 64), (65, 200), (201, 500), (501, 1000), (1001, 10000)]
for lo, hi in node_buckets:
count = sum(1 for n in nodes_list if lo <= n <= hi)
pct = 100*count/len(nodes_list) if nodes_list else 0
print(f" {lo}-{hi if hi < 10000 else 'inf'} nodes: {count} ({pct:.1f}%)")
# Show duration correlation with nodes
print("\nDuration by node count:")
for lo, hi in [(1, 64), (65, 200), (201, 500), (501, 1000), (1001, 10000)]:
subset_durations = [d for n, d in zip(nodes_list, durations) if lo <= n <= hi]
if subset_durations:
avg = sum(subset_durations) / len(subset_durations)
print(f" {lo}-{hi if hi < 10000 else 'inf'} nodes: avg {avg:.0f}µs, count {len(subset_durations)}")
check_nodes("pathfinding_benchmark_current.csv", "CURRENT")