2 Commits

Author SHA1 Message Date
herel b6d07d4d3c max threads to 48 2022-05-05 20:41:20 +02:00
herel 8a6b686490 display time take 2022-05-05 20:40:56 +02:00
2 changed files with 13 additions and 6 deletions
+12 -5
View File
@@ -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();
}
+1 -1
View File
@@ -81,7 +81,7 @@ impl Population {
let mut stats: [i32; 4] = [0, 0, 0, 0];
let num_threads = num_threads.unwrap_or(1);
if num_threads > 8 {
if num_threads > 48 {
panic!("too many threads")
}