Updated Synchronous code to record total time of execution
This commit is contained in:
parent
7ec01a8717
commit
a4949a0d6a
15
src/main.rs
15
src/main.rs
@ -28,23 +28,26 @@ async fn main() {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
const num_queries: u32 = 5_000;
|
||||
const NUM_QUERIES: u32 = 5_000;
|
||||
let collection = db.collection::<Packet>("test");
|
||||
let mut queries: Vec<std::time::Duration> = vec![];
|
||||
|
||||
for _ in 0..num_queries {
|
||||
let start_time = SystemTime::now();
|
||||
|
||||
for _ in 0..NUM_QUERIES {
|
||||
let query_time = SystemTime::now();
|
||||
|
||||
collection.insert_one(Packet{
|
||||
time: time::SystemTime::now(),
|
||||
text: format!("Current Unix time: {:?}", time::SystemTime::now().duration_since(time::UNIX_EPOCH).unwrap())
|
||||
time: SystemTime::now(),
|
||||
text: format!("Current Unix time: {:?}", SystemTime::now().duration_since(time::UNIX_EPOCH).unwrap())
|
||||
}, None).await.unwrap();
|
||||
|
||||
let duration = time::SystemTime::now().duration_since(start_time).unwrap();
|
||||
let duration = SystemTime::now().duration_since(query_time).unwrap();
|
||||
queries.push(duration);
|
||||
}
|
||||
|
||||
for (i, duration) in queries.iter().enumerate() {
|
||||
println!("{}: {}.{} milliseconds", i, duration.as_millis(), duration.as_micros());
|
||||
}
|
||||
|
||||
println!("Ran {} queries in {} seconds.", NUM_QUERIES, SystemTime::now().duration_since(start_time).unwrap().as_secs_f32());
|
||||
}
|
Loading…
Reference in New Issue
Block a user