コード例 #1
0
ファイル: DumpHeapJob.cs プロジェクト: alex-davidson/clrspy
        private void WriteHeapStatistics(IList<RawTypeInfo> allHeapInfo, TextWriter output)
        {
            var stats = allHeapInfo.Select(t => new {
                    t.TypeName,
                    SizeInBytes = Statistics.CalculateInPlace(t.SizesInBytes)
                })
                .OrderByDescending(s => s.SizeInBytes.Total)
                .ToList();

            var tabulator = new Tabulator(
                new Column("Total") { Width = 10, RightAlign = true },
                new Column("Count") { Width = 10, RightAlign = true  },
                new Column("Mean") { Width = 10, RightAlign = true  },
                new Column("StdDev") { Width = 10, RightAlign = true  },
                new Column("Median") { Width = 10, RightAlign = true  },
                new Column("Max") { Width = 10, RightAlign = true  },
                new Column("Type")
                ) { Defaults = { Padding = 2 } };
            output.WriteLine("Heap object types:");
            output.WriteLine(tabulator.GetHeader());
            foreach(var s in stats)
            {
                tabulator.Tabulate(output,
                    s.SizeInBytes.Total,
                    s.SizeInBytes.Count,
                    Math.Round(s.SizeInBytes.Mean),
                    s.SizeInBytes.StandardDeviation.ToString("0.0"),
                    Math.Round(s.SizeInBytes.Median),
                    s.SizeInBytes.Maximum,
                    s.TypeName);
                output.WriteLine();
            }
        }
コード例 #2
0
        public void HeaderDoesNotHaveTrailingLineBreak()
        {
            var tabulator = new Tabulator(
                new Column("A") { Width = 4 },
                new Column("B") { Width = 4 }
                ) { Defaults = { Padding = 0 } };

            var header = tabulator.GetHeader();
            Assert.That(header, Is.Not.StringContaining("\n"));
        }
コード例 #3
0
        public void HeaderAlignmentMatchesColumn()
        {
            var tabulator = new Tabulator(
                new Column("A") { Width = 4 },
                new Column("B") { Width = 4, RightAlign = true }
                ) { Defaults = { Padding = 0 } };

            var header = tabulator.GetHeader();
            Assert.That(header, Is.EqualTo("A      B"));
        }
コード例 #4
0
        private void WriteProcessList(IList<IProcessInfo> processes, ConsoleLog console)
        {
            if(!processes.Any()) return;
            var tabulator = new Tabulator(
                new Column("Pid") { Width = 5, RightAlign = true},
                new Column("Name") { Width = 20},
                new Column("Memory") { Width = 12, RightAlign = true},
                new Column("CLR Versions"))
            { Defaults = { Padding = 2 } };

            console.WriteLine($"{processes.Count} matching {ProcessArchitecture.FromCurrentProcess().Describe()} processes were found:");
            console.WriteLine(tabulator.GetHeader());
            foreach (var candidate in processes.OrderBy(c => c.Pid))
            {
                console.WriteLine(tabulator.Tabulate(candidate.Pid, candidate.Name, $"{candidate.WorkingSetSizeBytes.InKilobytes()} KB", DescribeCLRVersions(candidate)));
            }
        }