fix: show req number, use localtime

This commit is contained in:
əlemi 2024-10-19 05:29:32 +02:00
parent b1ab7f433a
commit f4ab2a327a
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -52,11 +52,11 @@ pub enum PostWomanActions {
const TIMESTAMP_FMT: &str = "%H:%M:%S%.6f";
fn print_results(res: String, name: String, before: chrono::DateTime<chrono::Utc>) {
let after = chrono::Utc::now();
fn print_results(res: String, name: String, before: chrono::DateTime<chrono::Local>, num: u32) {
let after = chrono::Local::now();
let elapsed = (after - before).num_milliseconds();
let timestamp = after.format(TIMESTAMP_FMT);
eprintln!(" + [{timestamp}] {name} done in {elapsed}ms", );
eprintln!(" + [{timestamp}] {name} #{num} done in {elapsed}ms", );
print!("{}", res);
}
@ -79,26 +79,26 @@ async fn main() -> Result<(), PostWomanError> {
let _endpoint = endpoint.clone();
let _name = name.clone();
let task = async move {
let before = chrono::Utc::now();
let before = chrono::Local::now();
eprintln!(" : [{}] sending {_name} #{}...", before.format(TIMESTAMP_FMT), i+1);
let res = _endpoint
.fill()
.execute(&_client)
.await;
(res, _name, before)
(res, _name, before, i)
};
if parallel {
joinset.spawn(task);
} else {
let (res, name, before) = task.await;
print_results(res?, name, before);
let (res, name, before, num) = task.await;
print_results(res?, name, before, num);
}
}
}
}
while let Some(j) = joinset.join_next().await {
match j {
Ok((res, name, before)) => print_results(res?, name, before),
Ok((res, name, before, num)) => print_results(res?, name, before, num),
Err(e) => eprintln!("! error joining task: {e}"),
}
}
@ -109,7 +109,5 @@ async fn main() -> Result<(), PostWomanError> {
// },
}
eprintln!();
Ok(())
}