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