Skip to content

Commit

Permalink
bench: wrap result from caller thread
Browse files Browse the repository at this point in the history
  • Loading branch information
grooviegermanikus committed Oct 4, 2023
1 parent 7cbefc8 commit 2ad4fcd
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ struct TxSendData {
transaction_bytes: u64,
}

struct ApiCallerResult {
gross_send_time: Duration,
}

#[allow(clippy::too_many_arguments)]
async fn bench(
rpc_client: Arc<RpcClient>,
Expand All @@ -168,7 +172,7 @@ async fn bench(
) -> Metric {
let map_of_txs: Arc<DashMap<Signature, TxSendData>> = Arc::new(DashMap::new());
// transaction sender task
let time_to_run = {
let api_caller_result = {
let map_of_txs = map_of_txs.clone();
let rpc_client = rpc_client.clone();
let current_slot = current_slot.clone();
Expand Down Expand Up @@ -210,7 +214,9 @@ async fn bench(
}
}
}
bench_start_time.elapsed()
ApiCallerResult {
gross_send_time: bench_start_time.elapsed(),
}
})
};

Expand Down Expand Up @@ -259,9 +265,13 @@ async fn bench(
for tx in map_of_txs.iter() {
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
Expand Down

0 comments on commit 2ad4fcd

Please sign in to comment.