11use std:: time:: Duration ;
22
33use console:: style;
4+ use tabled:: { Table , Tabled } ;
45use tokio:: time:: { Instant , sleep} ;
56
67use crate :: api_client:: {
@@ -14,6 +15,14 @@ use super::run_environment::RunEnvironmentProvider;
1415const RUN_PROCESSING_MAX_DURATION : Duration = Duration :: from_secs ( 60 * 5 ) ; // 5 minutes
1516const POLLING_INTERVAL : Duration = Duration :: from_secs ( 1 ) ;
1617
18+ #[ derive( Tabled ) ]
19+ struct BenchmarkRow {
20+ #[ tabled( rename = "Benchmark" ) ]
21+ name : String ,
22+ #[ tabled( rename = "Time" ) ]
23+ time : String ,
24+ }
25+
1726#[ allow( clippy:: borrowed_box) ]
1827pub async fn poll_results (
1928 api_client : & CodSpeedAPIClient ,
@@ -100,19 +109,29 @@ pub async fn poll_results(
100109
101110 if !response. run . results . is_empty ( ) {
102111 start_group ! ( "Benchmark results" ) ;
103- for result in response. run . results {
104- let benchmark_name = result. benchmark . name ;
105- let time = helpers:: format_duration ( result. time , Some ( 2 ) ) ;
106112
107- info ! ( "{}: {}" , benchmark_name, style( time) . bold( ) ) ;
108-
109- if output_json {
113+ let table_rows: Vec < BenchmarkRow > = response
114+ . run
115+ . results
116+ . iter ( )
117+ . map ( |result| BenchmarkRow {
118+ name : result. benchmark . name . clone ( ) ,
119+ time : helpers:: format_duration ( result. time , Some ( 2 ) ) ,
120+ } )
121+ . collect ( ) ;
122+
123+ let table = Table :: new ( & table_rows) . to_string ( ) ;
124+ info ! ( "\n {table}" ) ;
125+
126+ if output_json {
127+ for result in response. run . results {
110128 log_json ! ( format!(
111129 "{{\" event\" : \" benchmark_ran\" , \" name\" : \" {}\" , \" time\" : \" {}\" }}" ,
112- benchmark_name , result. time,
130+ result . benchmark . name , result. time,
113131 ) ) ;
114132 }
115133 }
134+
116135 end_group ! ( ) ;
117136 }
118137
0 commit comments