add execution time logs

This commit is contained in:
2025-08-14 14:47:01 +01:00
parent 6685a4d04a
commit 89129d32ee

View File

@@ -1,6 +1,7 @@
use std::io; use std::io;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::str::SplitWhitespace; use std::str::SplitWhitespace;
use std::time::SystemTime;
struct Orderbook { struct Orderbook {
// both of these maps map a price to a quantity // both of these maps map a price to a quantity
@@ -289,6 +290,8 @@ fn main() {
io::stdin().read_line(&mut input_string).unwrap(); io::stdin().read_line(&mut input_string).unwrap();
println!(); println!();
let start_time = SystemTime::now();
let mut split = input_string.split_whitespace(); let mut split = input_string.split_whitespace();
let command: Option<&str> = split.next(); let command: Option<&str> = split.next();
@@ -324,10 +327,15 @@ fn main() {
}; };
}, },
_ => { _ => {
panic!("Unknown command."); println!("Unknown command.");
} }
}; };
let end_time = SystemTime::now();
let difference = end_time.duration_since(start_time).unwrap();
println!();
println!("Executed in {}μs", difference.as_micros());
println!(); println!();
list_orders(&ob); list_orders(&ob);
} }