@@ -246,6 +246,8 @@ pub struct Iteration<IterData> {
246246 pub total_time : f64 ,
247247 /// The user provided annotation for this iteration
248248 pub data : IterData ,
249+ /// The number of rebuild iterations done after this iteration completed.
250+ pub n_rebuilds : usize ,
249251}
250252
251253type RunnerResult < T > = std:: result:: Result < T , StopReason > ;
@@ -316,6 +318,28 @@ where
316318 self
317319 }
318320
321+ #[ rustfmt:: skip]
322+ /// Prints some information about a runners run.
323+ pub fn print_report ( & self ) {
324+ let search_time: f64 = self . iterations . iter ( ) . map ( |i| i. search_time ) . sum ( ) ;
325+ let apply_time: f64 = self . iterations . iter ( ) . map ( |i| i. apply_time ) . sum ( ) ;
326+ let rebuild_time: f64 = self . iterations . iter ( ) . map ( |i| i. rebuild_time ) . sum ( ) ;
327+ let total_time: f64 = self . iterations . iter ( ) . map ( |i| i. total_time ) . sum ( ) ;
328+
329+ let iters = self . iterations . len ( ) ;
330+ let rebuilds: usize = self . iterations . iter ( ) . map ( |i| i. n_rebuilds ) . sum ( ) ;
331+
332+ println ! ( "Runner report" ) ;
333+ println ! ( "=============" ) ;
334+ println ! ( " Stop reason: {:?}" , self . stop_reason. as_ref( ) . unwrap( ) ) ;
335+ println ! ( " Iterations: {}" , iters) ;
336+ println ! ( " Rebuilds: {}, {:.2} per iter" , rebuilds, ( rebuilds as f64 ) / ( iters as f64 ) ) ;
337+ println ! ( " Total time: {}" , total_time) ;
338+ println ! ( " Search: ({:.2}) {}" , search_time / total_time, search_time) ;
339+ println ! ( " Apply: ({:.2}) {}" , apply_time / total_time, apply_time) ;
340+ println ! ( " Rebuild: ({:.2}) {}" , rebuild_time / total_time, rebuild_time) ;
341+ }
342+
319343 fn run_one ( & mut self , rules : & [ Rewrite < L , M > ] ) -> RunnerResult < ( ) > {
320344 assert ! ( self . stop_reason. is_none( ) ) ;
321345
@@ -369,7 +393,7 @@ where
369393 info ! ( "Apply time: {}" , apply_time) ;
370394
371395 let rebuild_time = Instant :: now ( ) ;
372- self . egraph . rebuild ( ) ;
396+ let n_rebuilds = self . egraph . rebuild ( ) ;
373397
374398 let rebuild_time = rebuild_time. elapsed ( ) . as_secs_f64 ( ) ;
375399 info ! ( "Rebuild time: {}" , rebuild_time) ;
@@ -388,6 +412,7 @@ where
388412 search_time,
389413 apply_time,
390414 rebuild_time,
415+ n_rebuilds,
391416 data : IterData :: make ( & self ) ,
392417 total_time : start_time. elapsed ( ) . as_secs_f64 ( ) ,
393418 } ) ;
0 commit comments