@@ -373,6 +373,17 @@ impl BenchmarkCommand {
373373 let this_exe =
374374 std:: env:: current_exe ( ) . context ( "failed to get the current executable's path" ) ?;
375375
376+ let wasm_files: Vec < _ > = self . benchmarks . iter ( ) . flat_map ( |b| b. paths ( ) ) . collect ( ) ;
377+ eprintln ! (
378+ "\n Running {} total iterations ({} engines * {} benchmarks * {} processes * {} iterations per process)" ,
379+ self . engines. len( ) * wasm_files. len( ) * self . processes * self . iterations_per_process,
380+ self . engines. len( ) ,
381+ wasm_files. len( ) ,
382+ self . processes,
383+ self . iterations_per_process
384+ ) ;
385+ eprint ! ( "\n [Done] [Elapsed ] [Est. Rem. ]" ) ;
386+
376387 // Shuffle the order in which we spawn benchmark processes. This helps
377388 // us avoid some measurement bias from CPU state transitions that aren't
378389 // constrained within the duration of process execution, like dynamic
@@ -389,14 +400,18 @@ impl BenchmarkCommand {
389400 // and therefore potentially invalidating relative paths used here).
390401 let engine = check_engine_path ( engine) ?;
391402
392- for wasm in self . benchmarks . iter ( ) . flat_map ( |s| s . paths ( ) ) {
403+ for wasm in wasm_files . iter ( ) . cloned ( ) {
393404 choices. push ( ( engine. clone ( ) , wasm, self . processes ) ) ;
394405 }
395406 }
396407
397408 // Accumulated measurements from all of our subprocesses.
398409 let mut measurements = vec ! [ ] ;
399410
411+ let mut i = 0 ;
412+ let n = choices. len ( ) * self . processes ;
413+ let start = std:: time:: Instant :: now ( ) ;
414+
400415 while !choices. is_empty ( ) {
401416 let index = rng. gen_range ( 0 , choices. len ( ) ) ;
402417 let ( engine, wasm, procs_left) = & mut choices[ index] ;
@@ -458,7 +473,33 @@ impl BenchmarkCommand {
458473 String :: from_utf8_lossy( & output. stdout)
459474 ) ;
460475
461- eprintln ! ( "." ) ;
476+ const PRINT_EVERY : usize = 10 ;
477+ i += 1 ;
478+ debug_assert ! ( i <= n) ;
479+ if i % PRINT_EVERY == 1 {
480+ let percent_done = ( i as f64 ) / ( n as f64 ) * 100.0 ;
481+
482+ let elapsed = start. elapsed ( ) . as_secs ( ) ;
483+ let elapsed_hours = elapsed / 60 / 60 ;
484+ let elapsed_mins = elapsed / 60 % 60 ;
485+ let elapsed_secs = elapsed % 60 ;
486+
487+ let secs_per_proc = ( elapsed as f64 ) / ( i as f64 ) ;
488+ let procs_left = n - i;
489+ let eta = ( procs_left as f64 ) * secs_per_proc;
490+ let eta = eta. round ( ) as u64 ;
491+ let eta_hours = eta / 60 / 60 ;
492+ let eta_mins = eta / 60 % 60 ;
493+ let eta_secs = eta % 60 ;
494+
495+ eprint ! (
496+ "\n \
497+ [{percent_done:>3.0}%] \
498+ [{elapsed_hours:02}h:{elapsed_mins:02}m:{elapsed_secs:02}s] \
499+ [{eta_hours:02}h:{eta_mins:02}m:{eta_secs:02}s] ",
500+ )
501+ }
502+ eprint ! ( "." ) ;
462503
463504 // Parse the subprocess's output and add its measurements to our
464505 // accumulation.
@@ -473,6 +514,12 @@ impl BenchmarkCommand {
473514 }
474515 }
475516
517+ let elapsed = start. elapsed ( ) ;
518+ let hours = elapsed. as_secs ( ) / 60 / 60 ;
519+ let mins = elapsed. as_secs ( ) / 60 % 60 ;
520+ let secs = elapsed. as_secs ( ) % 60 ;
521+ eprintln ! ( "\n \n Finished benchmarking in {hours:02}h:{mins:02}m:{secs:02}s" ) ;
522+
476523 self . write_results ( & measurements, & mut output_file) ?;
477524 Ok ( ( ) )
478525 }
0 commit comments