|
2 | 2 | //! errors.
|
3 | 3 |
|
4 | 4 | use std::{
|
5 |
| - env, |
| 5 | + env, fmt, |
6 | 6 | time::{SystemTime, UNIX_EPOCH},
|
7 | 7 | };
|
8 | 8 |
|
@@ -152,6 +152,11 @@ impl flags::AnalysisStats {
|
152 | 152 | let item_tree_time = item_tree_sw.elapsed();
|
153 | 153 |
|
154 | 154 | eprintln!("Source stats:");
|
| 155 | + let dep_loc = UsizeWithUnderscore(dep_loc); |
| 156 | + let deps_item_trees = UsizeWithUnderscore(deps_item_trees); |
| 157 | + let workspace_loc = UsizeWithUnderscore(workspace_loc); |
| 158 | + let workspace_item_trees = UsizeWithUnderscore(workspace_item_trees); |
| 159 | + |
155 | 160 | eprintln!(" dependency lines of code: {dep_loc}, item trees: {deps_item_trees}");
|
156 | 161 | eprintln!(" workspace lines of code: {workspace_loc}, item trees: {workspace_item_trees}");
|
157 | 162 |
|
@@ -1243,6 +1248,32 @@ fn percentage(n: u64, total: u64) -> u64 {
|
1243 | 1248 | (n * 100).checked_div(total).unwrap_or(100)
|
1244 | 1249 | }
|
1245 | 1250 |
|
| 1251 | +struct UsizeWithUnderscore(usize); |
| 1252 | + |
| 1253 | +impl fmt::Display for UsizeWithUnderscore { |
| 1254 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 1255 | + let num_str = self.0.to_string(); |
| 1256 | + |
| 1257 | + if num_str.len() <= 3 { |
| 1258 | + return write!(f, "{}", num_str); |
| 1259 | + } |
| 1260 | + |
| 1261 | + let mut result = String::new(); |
| 1262 | + let mut count = 0; |
| 1263 | + |
| 1264 | + for ch in num_str.chars().rev() { |
| 1265 | + if count > 0 && count % 3 == 0 { |
| 1266 | + result.push('_'); |
| 1267 | + } |
| 1268 | + result.push(ch); |
| 1269 | + count += 1; |
| 1270 | + } |
| 1271 | + |
| 1272 | + let result = result.chars().rev().collect::<String>(); |
| 1273 | + write!(f, "{}", result) |
| 1274 | + } |
| 1275 | +} |
| 1276 | + |
1246 | 1277 | // FIXME(salsa-transition): bring this back whenever we implement
|
1247 | 1278 | // Salsa's memory usage tracking to work with tracked functions.
|
1248 | 1279 | // fn syntax_len(node: SyntaxNode) -> usize {
|
|
0 commit comments