diff --git a/Cargo.lock b/Cargo.lock index b1f6619..041afc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -371,6 +371,28 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indicatif" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -450,6 +472,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "once_cell" version = "1.19.0" @@ -500,6 +528,12 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -613,6 +647,8 @@ dependencies = [ "criterion", "dialoguer", "env_logger", + "indicatif", + "itertools 0.13.0", "log", "num_cpus", "petgraph", diff --git a/Cargo.toml b/Cargo.toml index 8c046d8..48ff71d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,8 @@ log = "0.4.22" env_logger = "0.11.5" rayon = "1.10.0" byteorder = "1.5.0" +itertools = "0.13.0" +indicatif = "0.17.8" [dev-dependencies] criterion = { version = "0.3", features = ["html_reports"] } diff --git a/src/clustering/layer.rs b/src/clustering/layer.rs index 8de08c7..5e74cda 100644 --- a/src/clustering/layer.rs +++ b/src/clustering/layer.rs @@ -8,6 +8,8 @@ use crate::clustering::abstraction::Abstraction; use crate::clustering::histogram::Histogram; use crate::clustering::metric::Metric; use crate::clustering::xor::Pair; +use indicatif::ProgressBar; +use indicatif::ProgressStyle; use rand::distributions::Distribution; use rand::distributions::WeightedIndex; use rand::rngs::StdRng; @@ -77,7 +79,7 @@ impl Layer { /// simply go to the previous street fn inner_street(&self) -> Street { log::info!( - "advancing street from {} to {}", + "advancing street from {} -> {}", self.street, self.street.prev() ); @@ -91,7 +93,7 @@ impl Layer { /// the distnace isn't symmetric in the first place only because our heuristic algo is not fully accurate fn inner_metric(&self) -> Metric { log::info!( - "computing metric from {} to {}", + "computing metric from {} -> {}", self.street, self.street.prev() ); @@ -119,10 +121,19 @@ impl Layer { /// 4. collect `Abstraction`s into a `Histogram`, for each `Observation` fn inner_points(&self) -> ObservationSpace { log::info!( - "computing projections from {} to {}", + "computing projections from {} -> {}", self.street, self.street.prev() ); + // pretty progress bar + let n = self.street.prev().n_isomorphisms() as u64; + let tick = std::time::Duration::from_secs(5); + let style = "[{elapsed}] {spinner:.green} {wide_bar:.green} ETA {eta}"; + let style = ProgressStyle::with_template(style).unwrap(); + let progress = ProgressBar::new(n); + progress.set_style(style); + progress.enable_steady_tick(tick); + // ObservationSpace( Observation::exhaust(self.street.prev()) .filter(|o| Isomorphism::is_canonical(o)) @@ -130,6 +141,7 @@ impl Layer { .collect::>() // isomorphism translation .into_par_iter() .map(|inner| (inner, self.lookup.projection(&inner))) + .inspect(|_| progress.inc(1)) .collect::>(), ) }