Skip to content

Commit 12eaa3a

Browse files
committed
Print total node count in -Z hir-stats
1 parent 8adb4b3 commit 12eaa3a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

compiler/rustc_passes/src/hir_stats.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ impl<'k> StatCollector<'k> {
126126
});
127127

128128
let total_size = nodes.iter().map(|(_, node)| node.stats.count * node.stats.size).sum();
129+
let total_count = nodes.iter().map(|(_, node)| node.stats.count).sum();
129130

130131
eprintln!("{prefix} {title}");
131132
eprintln!(
@@ -167,7 +168,13 @@ impl<'k> StatCollector<'k> {
167168
}
168169
}
169170
eprintln!("{prefix} ----------------------------------------------------------------");
170-
eprintln!("{} {:<18}{:>10}", prefix, "Total", to_readable_str(total_size));
171+
eprintln!(
172+
"{} {:<18}{:>10} {:>14}",
173+
prefix,
174+
"Total",
175+
to_readable_str(total_size),
176+
to_readable_str(total_count),
177+
);
171178
eprintln!("{prefix}");
172179
}
173180
}

tests/ui/stats/hir-stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ check-pass
22
//@ compile-flags: -Zhir-stats
3-
//@ only-x86_64
3+
//@ only-64bit
44
// layout randomization affects the hir stat output
55
//@ needs-deterministic-layouts
66

tests/ui/stats/hir-stats.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ast-stats-1 - Enum 136 ( 2.0%) 1
5353
ast-stats-1 - Fn 272 ( 4.1%) 2
5454
ast-stats-1 - Use 408 ( 6.1%) 3
5555
ast-stats-1 ----------------------------------------------------------------
56-
ast-stats-1 Total 6_640
56+
ast-stats-1 Total 6_640 116
5757
ast-stats-1
5858
ast-stats-2 POST EXPANSION AST STATS
5959
ast-stats-2 Name Accumulated Size Count Item Size
@@ -113,7 +113,7 @@ ast-stats-2 - ForeignMod 136 ( 1.9%) 1
113113
ast-stats-2 - Fn 272 ( 3.7%) 2
114114
ast-stats-2 - Use 544 ( 7.5%) 4
115115
ast-stats-2 ----------------------------------------------------------------
116-
ast-stats-2 Total 7_288
116+
ast-stats-2 Total 7_288 127
117117
ast-stats-2
118118
hir-stats HIR STATS
119119
hir-stats Name Accumulated Size Count Item Size
@@ -174,5 +174,5 @@ hir-stats - Use 352 ( 3.9%) 4
174174
hir-stats Path 1_240 (13.7%) 31 40
175175
hir-stats PathSegment 1_920 (21.3%) 40 48
176176
hir-stats ----------------------------------------------------------------
177-
hir-stats Total 9_024
177+
hir-stats Total 9_024 180
178178
hir-stats

0 commit comments

Comments
 (0)