diff options
author | Ivan Diaz Sanchez <ivdiazsa@microsoft.com> | 2021-05-20 22:46:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-20 22:46:20 +0300 |
commit | 80c81b39ae7ab7d8125e94fae1a7615368beab7b (patch) | |
tree | 9e621077a186fd1920be19965e59f22ca27b184d /src/coreclr/tools/r2rdump | |
parent | aaaaeed8c8d2d01dccd1f7fc536ea27eee75f472 (diff) |
Print R2RDump Statistics in the Output File Instead of Console (#52278)
* Moved R2RDump statistics from console to --out file
* Automated the fixup statistics report into a self-maintaining component.
* Optimized the minimum values by setting them at the beginning, and removing the Math.Max() calls.
Diffstat (limited to 'src/coreclr/tools/r2rdump')
-rw-r--r-- | src/coreclr/tools/r2rdump/TextDumper.cs | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/coreclr/tools/r2rdump/TextDumper.cs b/src/coreclr/tools/r2rdump/TextDumper.cs index 613c0bb96ea..0e062b88508 100644 --- a/src/coreclr/tools/r2rdump/TextDumper.cs +++ b/src/coreclr/tools/r2rdump/TextDumper.cs @@ -561,13 +561,51 @@ namespace R2RDump Count = group.Count() }).OrderByDescending(x => x.Count); - Console.WriteLine($" Fixup | Count"); + /* Runtime Repo GH Issue #49249: + * + * In order to format the fixup counts results table, we need to + * know beforehand the size of each column. The padding is calculated + * as follows: + * + * Fixup: Length of the longest Fixup Kind name. + * Count: Since a total is always bigger than its operands, we set + * the padding to the total's number of digits. + * + * The reason we want them to be at least 5, is because in the case of only + * getting values shorter than 5 digits (Length of "Fixup" and "Count"), + * the formatting could be messed up. The likelyhood of this happening + * is apparently 0%, but better safe than sorry. */ + + int fixupPadding = 5; + int sortedFixupCountsTotal = sortedFixupCounts.Sum(x => x.Count); + int countPadding = Math.Max(sortedFixupCountsTotal.ToString().Length, 5); + + /* We look at all the Fixup Kinds that will be printed. We + * then store the length of the longest one's name. */ + foreach (var fixupAndCount in sortedFixupCounts) { - Console.WriteLine($"{fixupAndCount.FixupKind, 27} | {fixupAndCount.Count, 5}"); + int kindLength = fixupAndCount.FixupKind.ToString().Length; + + if (kindLength > fixupPadding) + fixupPadding = kindLength; } - Console.WriteLine("-----------------------------------"); - Console.WriteLine($" Total | {sortedFixupCounts.Sum(x => x.Count), 5}"); + + _writer.WriteLine( + $"{"Fixup".PadLeft(fixupPadding)} | {"Count".PadLeft(countPadding)}" + ); + foreach (var fixupAndCount in sortedFixupCounts) + { + _writer.WriteLine( + $"{fixupAndCount.FixupKind.ToString().PadLeft(fixupPadding)} | {fixupAndCount.Count.ToString().PadLeft(countPadding)}" + ); + } + + // The +3 in this divider is to account for the " | " table division. + _writer.WriteLine(new string('-', fixupPadding + countPadding + 3)); + _writer.WriteLine( + $"{"Total".PadLeft(fixupPadding)} | {sortedFixupCountsTotal.ToString().PadLeft(countPadding)}" + ); SkipLine(); } } |