some stats

This commit is contained in:
Simon Gardling 2021-03-29 12:35:31 +00:00
parent e07aa5ca0a
commit d46abdfdd4
2 changed files with 14 additions and 67 deletions

65
Cargo.lock generated
View File

@ -14,21 +14,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "arrayfire"
version = "3.8.0"
source = "git+https://github.com/arrayfire/arrayfire-rust.git#89528902409a849ee92c982d19024789112e510c"
dependencies = [
"half",
"lazy_static",
"libc",
"num",
"rustc_version",
"serde",
"serde_derive",
"serde_json",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -324,7 +309,7 @@ dependencies = [
"gif",
"jpeg-decoder",
"num-iter",
"num-rational 0.3.2",
"num-rational",
"num-traits",
"png",
"scoped_threadpool",
@ -447,41 +432,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "num"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36"
dependencies = [
"num-bigint",
"num-complex",
"num-integer",
"num-iter",
"num-rational 0.2.4",
"num-traits",
]
[[package]]
name = "num-bigint"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.44"
@ -503,18 +453,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
dependencies = [
"autocfg",
"num-bigint",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.3.2"
@ -562,7 +500,6 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
name = "physarum"
version = "0.1.0"
dependencies = [
"arrayfire",
"chrono",
"criterion",
"image",

View File

@ -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) {