From 903142aee32b90ec945f809358eec3849e328e39 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 1 Aug 2016 19:56:19 -0400 Subject: [PATCH] dump statistics about re-use w/ -Z time-passes It's nice to get a rough idea of how much work we're saving. --- src/librustc_trans/back/write.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 87815c63f79..4b8d6776f22 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -724,6 +724,10 @@ pub fn run_passes(sess: &Session, work_items.push(work); } + if sess.time_passes() && sess.opts.incremental.is_some() { + dump_incremental_data(&trans); + } + // Process the work items, optionally using worker threads. // NOTE: This code is not really adapted to incremental compilation where // the compiler decides the number of codegen units (and will @@ -901,6 +905,17 @@ pub fn run_passes(sess: &Session, } } +fn dump_incremental_data(trans: &CrateTranslation) { + let mut reuse = 0; + for mtrans in trans.modules.iter() { + match mtrans.source { + ModuleSource::Preexisting(..) => reuse += 1, + ModuleSource::Translated(..) => (), + } + } + println!("incremental: re-using {} out of {} modules", reuse, trans.modules.len()); +} + struct WorkItem { mtrans: ModuleTranslation, config: ModuleConfig,