public override void Run(OutfileReader reader, string [] args) { Table table; table = new Table (); table.AddRow ("SUMMARY", ""); table.AddRow ("", ""); table.AddRow ("Filename:", reader.Filename); table.AddRow ("Allocated Bytes:", Util.PrettySize (reader.TotalAllocatedBytes)); table.AddRow ("Allocated Objects:", reader.TotalAllocatedObjects); table.AddRow ("GCs:", reader.Gcs.Length); table.AddRow ("Resizes:", reader.Resizes.Length); table.AddRow ("Final heap size:", Util.PrettySize (reader.LastResize.NewSize)); table.AddRow ("", ""); table.AddRow ("Distinct Types:", reader.Types.Length); table.AddRow ("Backtraces:", reader.Backtraces.Length); table.SetAlignment (1, Alignment.Left); Console.WriteLine (table); }
public override void Run(OutfileReader reader, string [] args) { Table table; table = new Table (); table.Separator = " | "; Resize [] resizes; resizes = reader.Resizes; Gc [] gcs; gcs = reader.Gcs; int i_resize = 0; int i_gc = 0; long heap_size = 0; while (i_resize < resizes.Length || i_gc < gcs.Length) { Resize r = null; if (i_resize < resizes.Length) r = resizes [i_resize]; Gc gc = null; if (i_gc < gcs.Length) gc = gcs [i_gc]; if (i_resize != 0 || i_gc != 0) table.AddRow ("", "", ""); string timestamp, tag, message; if (r != null && (gc == null || r.Generation <= gc.Generation)) { timestamp = string.Format ("{0:HH:mm:ss}", r.Timestamp); if (r.PreviousSize == 0) { tag = "Init"; message = String.Format ("Initialized heap to {0}", Util.PrettySize (r.NewSize)); } else { tag = "Resize"; message = String.Format ("Grew heap from {0} to {1}\n" + "{2} in {3} live objects\n" + "Heap went from {4:0.0}% to {5:0.0}% capacity", Util.PrettySize (r.PreviousSize), Util.PrettySize (r.NewSize), Util.PrettySize (r.TotalLiveBytes), r.TotalLiveObjects, r.PreResizeCapacity, r.PostResizeCapacity); } heap_size = r.NewSize; ++i_resize; } else { timestamp = String.Format ("{0:HH:mm:ss}", gc.Timestamp); if (gc.Generation >= 0) { tag = "GC " + gc.Generation; message = String.Format ("Collected {0} of {1} objects ({2:0.0}%)\n" + "Collected {3} of {4} ({5:0.0}%)\n" + "Heap went from {6:0.0}% to {7:0.0}% capacity", gc.FreedObjects, gc.PreGcLiveObjects, gc.FreedObjectsPercentage, Util.PrettySize (gc.FreedBytes), Util.PrettySize (gc.PreGcLiveBytes), gc.FreedBytesPercentage, 100.0 * gc.PreGcLiveBytes / heap_size, 100.0 * gc.PostGcLiveBytes / heap_size); } else { tag = "Exit"; message = String.Format ("{0} live objects using {1}", gc.PreGcLiveObjects, Util.PrettySize (gc.PreGcLiveBytes)); } ++i_gc; } table.AddRow (timestamp, tag, message); } table.SetAlignment (1, Alignment.Left); table.SetAlignment (2, Alignment.Left); Console.WriteLine (table); }
public override void Run(OutfileReader reader, string [] args) { SortOrder order = SortOrder.ByTotalBytes; int max_rows = 25; string match_string = null; bool ellipsize_names = true; // Hacky free-form arg parser int i = 0; while (i < args.Length) { string arg = args [i].ToLower (); if (arg == "count") order = SortOrder.ByCount; else if (arg == "total") order = SortOrder.ByTotalBytes; else if (arg == "average") order = SortOrder.ByAverageBytes; else if (arg == "age") order = SortOrder.ByAverageAge; else if (arg == "backtrace" || arg == "backtraces" || arg == "bt") order = SortOrder.ByBacktraceCount; else if (arg == "all") max_rows = -1; else if (arg == "match" || arg == "matching" || arg == "like") { ++i; match_string = args [i]; } else if (arg == "full" || arg == "long" || arg == "unellipsized") ellipsize_names = false; else { int n = -1; try { n = Int32.Parse (arg); } catch { } if (n > 0) max_rows = n; } ++i; } // Generate the table Table table; table = new Table (); table.AddHeaders ("Type", "#", "Total", "AvSz", "AvAge", "BT#"); if (ellipsize_names) table.SetStringify (0, Util.Ellipsize); table.SetStringify (2, Util.PrettySize_Obj); table.SetStringify (3, "0.0"); table.SetStringify (4, "0.0"); foreach (Type type in reader.Types) { if (match_string != null && ! type.Matches (match_string)) continue; table.AddRow (type.Name, type.LastObjectStats.AllocatedCount, type.LastObjectStats.AllocatedTotalBytes, type.LastObjectStats.AllocatedAverageBytes, type.LastObjectStats.AllocatedAverageAge, type.BacktraceCount); } switch (order) { case SortOrder.ByCount: table.Sort (1, false); break; case SortOrder.ByTotalBytes: table.Sort (2, false); break; case SortOrder.ByAverageBytes: table.Sort (3, false); break; case SortOrder.ByAverageAge: table.Sort (4, false); break; case SortOrder.ByBacktraceCount: table.Sort (5, false); break; } if (max_rows > 0) table.MaxRows = max_rows; Console.WriteLine (table); if (table.RowCount > table.MaxRows) { Console.WriteLine (); Console.WriteLine ("(skipped {0} types)", table.RowCount - table.MaxRows); } }