From 821d12bae4b15722c934098643501744dc4c1f1c Mon Sep 17 00:00:00 2001 From: keroro Date: Thu, 5 Aug 2021 00:58:54 +0800 Subject: [PATCH] chore(ckb-bench): log progress during preparing --- ckb-bench/src/prepare.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ckb-bench/src/prepare.rs b/ckb-bench/src/prepare.rs index cf903ad..2de1f5b 100644 --- a/ckb-bench/src/prepare.rs +++ b/ckb-bench/src/prepare.rs @@ -10,6 +10,7 @@ use ckb_types::{ }; use std::cmp::min; use std::collections::VecDeque; +use std::time::{Duration, Instant}; /// count of two-in-two-out txs a block should capable to package. const TWO_IN_TWO_OUT_COUNT: u64 = 1_000; @@ -55,6 +56,7 @@ pub fn dispatch( let total_outs = users.len() * cells_per_user as usize; let index_user = |out_i: usize| out_i % (cells_per_user as usize); + ckb_testkit::info!("constructing transactions..."); let mut i_out = 0usize; let mut txs = Vec::new(); while let Some(input) = live_cells.pop_front() { @@ -127,8 +129,14 @@ pub fn dispatch( } assert!(i_out == total_outs); - for tx in txs { - let result = maybe_retry_send_transaction(&nodes[0], &tx); + let total_txs = txs.len(); + let mut last_logging_time = Instant::now(); + for (i, tx) in txs.iter().enumerate() { + let result = maybe_retry_send_transaction(&nodes[0], tx); + if last_logging_time.elapsed() > Duration::from_secs(30) { + last_logging_time = Instant::now(); + ckb_testkit::info!("sent {}/{} collect-transactions", i + 1, total_txs) + } assert!( result.is_ok(), "dispatch-transaction should be ok but got {}", @@ -176,8 +184,14 @@ pub fn collect(nodes: &[Node], owner: &User, users: &[User]) { } } - for tx in txs { - let result = maybe_retry_send_transaction(&nodes[0], &tx); + let total_txs = txs.len(); + let mut last_logging_time = Instant::now(); + for (i, tx) in txs.iter().enumerate() { + let result = maybe_retry_send_transaction(&nodes[0], tx); + if last_logging_time.elapsed() > Duration::from_secs(30) { + last_logging_time = Instant::now(); + ckb_testkit::info!("sent {}/{} collect-transactions", i + 1, total_txs) + } assert!( result.is_ok(), "collect-transaction should be ok but got {}",