From 7cb20cd594428f5397f6159115d5e070e8c0935f Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Sun, 18 Aug 2024 23:29:55 +0000 Subject: [PATCH] dial down the trie stats --- core/src/toktree.rs | 50 ++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/core/src/toktree.rs b/core/src/toktree.rs index bd18b88..0b795db 100644 --- a/core/src/toktree.rs +++ b/core/src/toktree.rs @@ -887,38 +887,50 @@ impl TokTrie { } let mut histogram = String::new(); - for (idx, num) in nodes_histogram.iter().enumerate() { - if *num > 0 { - if !histogram.is_empty() { - histogram.push_str(", "); + + if false { + for (idx, num) in nodes_histogram.iter().enumerate() { + if *num > 0 { + if !histogram.is_empty() { + histogram.push_str(", "); + } + histogram.push_str(&format!("{}:{}", idx, num)); } - histogram.push_str(&format!("{}:{}", idx, num)); } } - for n in self.node_children(self.root()) { - histogram.push_str(&format!( - "\n{} => {} {}", - n.byte(), - self.node_children(n).count(), - n.subtree_size() - )); + if false { + for n in self.node_children(self.root()) { + histogram.push_str(&format!( + "\n{} => {} {}", + n.byte(), + self.node_children(n).count(), + n.subtree_size() + )); + } + } + + if false { + for depth in 0..30 { + let (count, num_tokens) = self.count_until_depth(depth); + histogram.push_str(&format!( + "\ndepth {}: {} nodes {} tokens", + depth, count, num_tokens + )); + } } - for depth in 0..30 { - let (count, num_tokens) = self.count_until_depth(depth); - histogram.push_str(&format!( - "\ndepth {}: {} nodes {} tokens", - depth, count, num_tokens - )); + if histogram.len() > 0 { + histogram = format!("\n{}", histogram); } format!( - "{}\n{} nodes, {} token nodes, {} token bytes", + "{}{} nodes, {} token nodes, {} token bytes, {} max len", histogram, self.nodes.len(), token_nodes, self.token_data.len(), + self.max_token_len, ) } }