display time take
This commit is contained in:
+12
-5
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user