removing oncecell and returning time taken to complete tokio task
This commit is contained in:
parent
2533ff4778
commit
7cbefc8d0c
|
@ -17,7 +17,6 @@ use std::sync::{
|
||||||
atomic::{AtomicU64, Ordering},
|
atomic::{AtomicU64, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
};
|
};
|
||||||
use tokio::sync::OnceCell;
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
sync::{mpsc::UnboundedSender, RwLock},
|
sync::{mpsc::UnboundedSender, RwLock},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
|
@ -168,13 +167,11 @@ async fn bench(
|
||||||
transaction_size: TransactionSize,
|
transaction_size: TransactionSize,
|
||||||
) -> 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());
|
||||||
let total_gross_send_time = Arc::new(OnceCell::new());
|
|
||||||
// transaction sender task
|
// transaction sender task
|
||||||
{
|
let time_to_run = {
|
||||||
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();
|
||||||
let total_gross_send_time = total_gross_send_time.clone();
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let map_of_txs = map_of_txs.clone();
|
let map_of_txs = map_of_txs.clone();
|
||||||
let n_chars = match transaction_size {
|
let n_chars = match transaction_size {
|
||||||
|
@ -213,11 +210,9 @@ async fn bench(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
total_gross_send_time
|
bench_start_time.elapsed()
|
||||||
.set(bench_start_time.elapsed())
|
})
|
||||||
.unwrap();
|
};
|
||||||
});
|
|
||||||
} // -- main act: send the transactions
|
|
||||||
|
|
||||||
let mut metric = Metric::default();
|
let mut metric = Metric::default();
|
||||||
let confirmation_time = Instant::now();
|
let confirmation_time = Instant::now();
|
||||||
|
@ -264,10 +259,9 @@ 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(
|
metric.set_total_gross_send_time(total_gross_send_time.as_micros() as f64 / 1_000.0);
|
||||||
total_gross_send_time.get().unwrap().as_micros() as f64 / 1_000.0,
|
}
|
||||||
);
|
|
||||||
|
|
||||||
metric.finalize();
|
metric.finalize();
|
||||||
metric
|
metric
|
||||||
|
|
Loading…
Reference in New Issue