Skip to content

Commit

Permalink
tightened time elapsed (MystenLabs#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxade authored Feb 5, 2022
1 parent 8df9755 commit 6971520
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions fastpay/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,17 @@ impl ClientServerBenchmark {
}

async fn launch_client(&self, connections: usize, mut orders: Vec<Bytes>) {
// Give the server time to be ready
time::sleep(Duration::from_millis(1000)).await;

let order_len_factor = if self.benchmark_type == BenchmarkType::OrdersAndCerts {
2
} else {
1
};
let items_number = orders.len() / order_len_factor;
let time_start = Instant::now();
let mut elapsed_time: u128 = 0;

// let connections: usize = num_cpus::get();
let max_in_flight = self.max_in_flight / connections as usize;
info!("Number of TCP connections: {}", connections);
info!("Set max_in_flight to {}", max_in_flight);
Expand All @@ -298,10 +299,13 @@ impl ClientServerBenchmark {
Duration::from_micros(self.recv_timeout_us),
);

let time_start = Instant::now();
let responses = mass_client
.batch_send(orders, connections, max_in_flight as u64)
.concat()
.await;
elapsed_time = time_start.elapsed().as_micros();

info!("Received {} responses.", responses.len(),);
// Check the responses for errors
for resp in &responses {
Expand Down Expand Up @@ -335,10 +339,12 @@ impl ClientServerBenchmark {
info!("Process message {}...", orders.len());
}
let order = orders.pop().unwrap();
let status = client
.send_recv_bytes(order.to_vec())
.await
.and_then(deserialize_object_info);

let time_start = Instant::now();
let resp = client.send_recv_bytes(order.to_vec()).await;
elapsed_time += time_start.elapsed().as_micros();
let status = deserialize_object_info(resp.unwrap());

match status {
Ok(info) => {
debug!("Query response: {:?}", info);
Expand All @@ -350,13 +356,12 @@ impl ClientServerBenchmark {
}
}

let time_total = time_start.elapsed().as_micros();
warn!(
"Completed benchmark for {}\nTotal time: {}us, items: {}, tx/sec: {}",
self.benchmark_type,
time_total,
elapsed_time,
items_number,
1_000_000.0 * (items_number as f64) / (time_total as f64)
1_000_000.0 * (items_number as f64) / (elapsed_time as f64)
);
}
}

0 comments on commit 6971520

Please sign in to comment.