diff --git a/src/main.rs b/src/main.rs index 4f71c27..361ffd5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,12 +13,16 @@ mod prelude { use prelude::*; use clap::Parser; +use std::time::Instant; #[derive(Parser, Debug)] struct Args { /// Number of threads #[clap(short, long, default_value_t = 1)] threads: usize, + /// Display stats after each propagation + #[clap(short, long)] + display: bool, } fn main() { @@ -37,18 +41,21 @@ fn main() { let mut stats: [i32; 4]; // = [0,0,0,0]; let mut counter: u32 = 0; + let now = Instant::now(); loop { counter += 1; stats = population.propagate_new(Some(args.threads)); //population.display(); - println!( - "Normal: {} Infecteds: {} Immunes: {} Deads: {}", - stats[0], stats[1], stats[2], stats[3] - ); + if args.display { + println!( + "Normal: {} Infecteds: {} Immunes: {} Deads: {}", + stats[0], stats[1], stats[2], stats[3] + ); + } if stats[1] == 0 { break; } } - println!("Propagation finished in {} steps", counter); + println!("Propagation finished in {} steps, {:?}", counter, now.elapsed()); //population.display(); }