@@ -59,12 +59,6 @@ use serde_json::Value;
5959use tokio:: task:: JoinSet ;
6060use tokio_util:: sync:: CancellationToken ;
6161use tracing:: { debug, error, info, warn, Instrument as _} ;
62- #[ cfg( feature = "benchmark" ) ]
63- use {
64- futures:: { stream, TryStreamExt } ,
65- linera_client:: benchmark:: BenchmarkError ,
66- linera_core:: client:: ChainClientError ,
67- } ;
6862
6963mod command;
7064mod net_up_utils;
@@ -750,6 +744,7 @@ impl Runnable for Job {
750744 close_chains,
751745 health_check_endpoints,
752746 wrap_up_max_in_flight,
747+ confirm_before_start,
753748 } => {
754749 assert ! ( num_chains > 0 , "Number of chains must be greater than 0" ) ;
755750 assert ! (
@@ -773,6 +768,22 @@ impl Runnable for Job {
773768 )
774769 . await ?;
775770
771+ if confirm_before_start {
772+ info ! ( "Ready to start benchmark. Say 'yes' when you want to proceed. Only 'yes' will be accepted" ) ;
773+ if !std:: io:: stdin ( )
774+ . lines ( )
775+ . next ( )
776+ . unwrap ( ) ?
777+ . eq_ignore_ascii_case ( "yes" )
778+ {
779+ info ! ( "Benchmark cancelled by user" ) ;
780+ context
781+ . wrap_up_benchmark ( chain_clients, close_chains, wrap_up_max_in_flight)
782+ . await ?;
783+ return Ok ( ( ) ) ;
784+ }
785+ }
786+
776787 linera_client:: benchmark:: Benchmark :: < S > :: run_benchmark (
777788 num_chains,
778789 transactions_per_block,
@@ -786,40 +797,9 @@ impl Runnable for Job {
786797 )
787798 . await ?;
788799
789- if close_chains {
790- info ! ( "Closing chains..." ) ;
791- let stream = stream:: iter ( chain_clients. values ( ) . cloned ( ) )
792- . map ( |chain_client| async move {
793- linera_client:: benchmark:: Benchmark :: < S > :: close_benchmark_chain (
794- & chain_client,
795- )
796- . await ?;
797- info ! ( "Closed chain {:?}" , chain_client. chain_id( ) ) ;
798- Ok :: < ( ) , BenchmarkError > ( ( ) )
799- } )
800- . buffer_unordered ( wrap_up_max_in_flight) ;
801- stream. try_collect :: < Vec < _ > > ( ) . await ?;
802- } else {
803- info ! ( "Processing inbox for all chains..." ) ;
804- let stream = stream:: iter ( chain_clients. values ( ) . cloned ( ) )
805- . map ( |chain_client| async move {
806- chain_client. process_inbox ( ) . await ?;
807- info ! ( "Processed inbox for chain {:?}" , chain_client. chain_id( ) ) ;
808- Ok :: < ( ) , ChainClientError > ( ( ) )
809- } )
810- . buffer_unordered ( wrap_up_max_in_flight) ;
811- stream. try_collect :: < Vec < _ > > ( ) . await ?;
812-
813- info ! ( "Updating wallet from chain clients..." ) ;
814- for chain_client in chain_clients. values ( ) {
815- context
816- . wallet
817- . as_mut ( )
818- . update_from_state ( chain_client)
819- . await ;
820- }
821- context. save_wallet ( ) . await ?;
822- }
800+ context
801+ . wrap_up_benchmark ( chain_clients, close_chains, wrap_up_max_in_flight)
802+ . await ?;
823803 }
824804
825805 Watch { chain_id, raw } => {
0 commit comments