diff options
| author | bors <bors@rust-lang.org> | 2015-11-12 04:06:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-11-12 04:06:48 +0000 |
| commit | 3bd622f94cfd0c6904dfac5390fc48c488e3aca2 (patch) | |
| tree | 5a7f1f0d01dacc8d1c7d8739fb599bdfef38bc65 /src/librustc_driver | |
| parent | 35decad78124b251822eb4666638455224d3f0c8 (diff) | |
| parent | f7dc917ba44c13e5ec00503dd82b857211437f48 (diff) | |
| download | rust-3bd622f94cfd0c6904dfac5390fc48c488e3aca2.tar.gz rust-3bd622f94cfd0c6904dfac5390fc48c488e3aca2.zip | |
Auto merge of #29764 - nrc:stats, r=nikomatsakis
Emits loc, and node count - before and after expansion. E.g., ``` rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore Lines of code: 32060 Pre-expansion node count: 120205 Post-expansion node count: 482749 ``` r? @nikomatsakis
Diffstat (limited to 'src/librustc_driver')
| -rw-r--r-- | src/librustc_driver/driver.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index d83bb411b4d..f2ca3652659 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -52,6 +52,8 @@ use syntax::feature_gate::UnstableFeatures; use syntax::fold::Folder; use syntax::parse; use syntax::parse::token; +use syntax::util::node_count::NodeCounter; +use syntax::visit; use syntax; pub fn compile_input(sess: Session, @@ -398,6 +400,11 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input) println!("{}", json::as_json(&krate)); } + if sess.opts.debugging_opts.input_stats { + println!("Lines of code: {}", sess.codemap().count_lines()); + println!("Pre-expansion node count: {}", count_nodes(&krate)); + } + if let Some(ref s) = sess.opts.show_span { syntax::show_span::run(sess.diagnostic(), s, &krate); } @@ -405,6 +412,12 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input) krate } +fn count_nodes(krate: &ast::Crate) -> usize { + let mut counter = NodeCounter::new(); + visit::walk_crate(&mut counter, krate); + counter.count +} + // For continuing compilation after a parsed crate has been // modified @@ -606,6 +619,10 @@ pub fn phase_2_configure_and_expand(sess: &Session, sess.abort_if_errors(); }); + if sess.opts.debugging_opts.input_stats { + println!("Post-expansion node count: {}", count_nodes(&krate)); + } + Some(krate) } |
