bench: wrap result from caller thread

This commit is contained in:
GroovieGermanikus 2023-10-04 18:50:11 +02:00
parent 7cbefc8d0c
commit 2ad4fcdb29
1 changed files with 15 additions and 5 deletions

View File

@ -154,6 +154,10 @@ struct TxSendData {
transaction_bytes: u64, transaction_bytes: u64,
} }
struct ApiCallerResult {
gross_send_time: Duration,
}
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
async fn bench( async fn bench(
rpc_client: Arc<RpcClient>, rpc_client: Arc<RpcClient>,
@ -168,7 +172,7 @@ async fn bench(
) -> Metric { ) -> Metric {
let map_of_txs: Arc<DashMap<Signature, TxSendData>> = Arc::new(DashMap::new()); let map_of_txs: Arc<DashMap<Signature, TxSendData>> = Arc::new(DashMap::new());
// transaction sender task // transaction sender task
let time_to_run = { let api_caller_result = {
let map_of_txs = map_of_txs.clone(); let map_of_txs = map_of_txs.clone();
let rpc_client = rpc_client.clone(); let rpc_client = rpc_client.clone();
let current_slot = current_slot.clone(); let current_slot = current_slot.clone();
@ -210,7 +214,9 @@ async fn bench(
} }
} }
} }
bench_start_time.elapsed() ApiCallerResult {
gross_send_time: bench_start_time.elapsed(),
}
}) })
}; };
@ -259,9 +265,13 @@ async fn bench(
for tx in map_of_txs.iter() { for tx in map_of_txs.iter() {
metric.add_unsuccessful_transaction(tx.sent_duration, tx.transaction_bytes); metric.add_unsuccessful_transaction(tx.sent_duration, tx.transaction_bytes);
} }
if let Ok(total_gross_send_time) = time_to_run.await {
metric.set_total_gross_send_time(total_gross_send_time.as_micros() as f64 / 1_000.0); let api_caller_result = api_caller_result
} .await
.expect("api caller task must succeed");
metric
.set_total_gross_send_time(api_caller_result.gross_send_time.as_micros() as f64 / 1_000.0);
metric.finalize(); metric.finalize();
metric metric