some stats
This commit is contained in:
16
src/model.rs
16
src/model.rs
@@ -181,6 +181,8 @@ impl Model {
|
||||
.progress_chars("#>-"),
|
||||
);
|
||||
|
||||
let mut time_per_agent_list: Vec<f64> = Vec::new();
|
||||
let mut time_per_step_list: Vec<f64> = Vec::new();
|
||||
for i in 0..steps {
|
||||
if debug {println!("Starting tick for all agents...")};
|
||||
|
||||
@@ -224,10 +226,14 @@ impl Model {
|
||||
agent.rotate_and_move(direction, rotation_angle, step_distance, width, height);
|
||||
});
|
||||
|
||||
|
||||
let agents_tick_elapsed: f64 = agents_tick_time.elapsed().as_millis() as f64;
|
||||
let ms_per_agent: f64 = (agents_tick_elapsed as f64) / (self.agents.len() as f64);
|
||||
time_per_agent_list.push(ms_per_agent);
|
||||
time_per_step_list.push(agents_tick_elapsed);
|
||||
|
||||
if debug {
|
||||
let agents_tick_elapsed = agents_tick_time.elapsed().as_millis();
|
||||
let ms_per_agent: f64 = (agents_tick_elapsed as f64) / (self.agents.len() as f64);
|
||||
println!("Finished tick for all agents. took {}ms\nTime per agent: {}ms\n", agents_tick_time.elapsed().as_millis(), ms_per_agent);
|
||||
println!("Finished tick for all agents. took {}ms\nTime per agent: {}ms\n", agents_tick_elapsed, ms_per_agent);
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +253,10 @@ impl Model {
|
||||
pb.set_position(i as u64);
|
||||
}
|
||||
pb.finish();
|
||||
|
||||
let avg_per_step: f64 = time_per_step_list.iter().sum::<f64>() as f64 / time_per_step_list.len() as f64;
|
||||
let avg_per_agent: f64 = time_per_step_list.iter().sum::<f64>() as f64 / time_per_step_list.len() as f64;
|
||||
println!("Average time per step: {}\nAverage time per agent: {}", avg_per_step, avg_per_agent);
|
||||
}
|
||||
|
||||
fn save_image_data(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user