Exemplo n.º 1
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")
            {
                Width = 12
            },
                new Column("App Pool"))
            {
                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), candidate.IISAppPoolName));
            }
        }
Exemplo n.º 2
0
        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();
            }
        }