diff --git a/internal/bsp/metrics.go b/internal/bsp/metrics.go new file mode 100644 index 0000000..33daf0e --- /dev/null +++ b/internal/bsp/metrics.go @@ -0,0 +1,31 @@ +package bsp + +type Stats struct { + Nodes int + Leaves int + MaxDepth int + TotalSegs int // Summe Segmente in Leaves (nach Splits) +} + +func Measure(n *Node) Stats { + var st Stats + var rec func(*Node, int) + rec = func(x *Node, d int) { + if x == nil { + return + } + if d > st.MaxDepth { + st.MaxDepth = d + } + if x.Leaf != nil { + st.Leaves++ + st.TotalSegs += len(x.Leaf.Segs) + return + } + st.Nodes++ + rec(x.Left, d+1) + rec(x.Right, d+1) + } + rec(n, 0) + return st +}