Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tooling for trie stats #8

Merged
merged 11 commits into from
Feb 8, 2024
Prev Previous commit
Next Next commit
Doc cleanup
  • Loading branch information
BGluth committed Feb 6, 2024
commit d0b1013cef224ed03c5c062ca4afb045a2bc1ccd
10 changes: 4 additions & 6 deletions src/debug_tools/stats.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Simple stat tooling to extract stats from tries.
//! Simple tooling to extract stats from tries.
//!
//! This is particularly useful when comparing a "base" trie against a sub-trie
//! This is particularly useful when comparing a "base" trie against a sub-trie (hashed out trie)
//! created from it.

use std::fmt::{self, Display};
Expand Down Expand Up @@ -110,8 +110,6 @@ pub struct TrieComparison {
}

impl Display for TrieComparison {
// Pretty debug is pretty good by default If we want something better, we can do
// our own.
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Node comparison: {}", self.node_comp)?;
writeln!(f, "Depth comparison: {}", self.depth_comp)
Expand Down Expand Up @@ -155,7 +153,7 @@ impl Display for DepthComparison {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Lowest depth: {}", self.lowest_depth_rat)?;
writeln!(f, "Avg leaf depth: {}", self.avg_leaf_depth_rat)?;
writeln!(f, "Avg hah depth: {}", self.avg_hash_depth_rat)
writeln!(f, "Avg hash depth: {}", self.avg_hash_depth_rat)
}
}

Expand All @@ -179,7 +177,7 @@ impl<T: Display + ToPrimitive> Display for RatioStat<T> {
}

impl<T: ToPrimitive> RatioStat<T> {
/// `new` doesn't do any logic, but this will reduce a lot of line lengths
/// `new` doesn't have any logic, but this will reduce a lot of line lengths
/// since this is called so many times.
fn new(a: T, b: T) -> Self {
Self { a, b }
Expand Down