Author: dsnell Date: 2006-07-24 19:08:56 -0400 (Mon, 24 Jul 2006) New Revision: 62935
Modified: branches/dmsnell/heap-buddy/analyzer/Backtrace.cs branches/dmsnell/heap-buddy/analyzer/Makefile branches/dmsnell/heap-buddy/analyzer/MemGraph.cs branches/dmsnell/heap-buddy/analyzer/MemlogReport.cs branches/dmsnell/heap-buddy/analyzer/OutfileReader.cs branches/dmsnell/heap-buddy/profiler/outfile-writer.c Log: Timestamps with allocs and graph beginnings Modified: branches/dmsnell/heap-buddy/analyzer/Backtrace.cs =================================================================== --- branches/dmsnell/heap-buddy/analyzer/Backtrace.cs 2006-07-24 22:54:42 UTC (rev 62934) +++ branches/dmsnell/heap-buddy/analyzer/Backtrace.cs 2006-07-24 23:08:56 UTC (rev 62935) @@ -29,6 +29,9 @@ public Type Type; public int LastGeneration; + + public long TimeT; + public DateTime Timestamp; public ObjectStats LastObjectStats; Modified: branches/dmsnell/heap-buddy/analyzer/Makefile =================================================================== --- branches/dmsnell/heap-buddy/analyzer/Makefile 2006-07-24 22:54:42 UTC (rev 62934) +++ branches/dmsnell/heap-buddy/analyzer/Makefile 2006-07-24 23:08:56 UTC (rev 62935) @@ -154,7 +154,7 @@ sysconfdir = ${prefix}/etc target_alias = CSC = mcs -debug -CSFLAGS = -target:exe +CSFLAGS = -target:exe -pkg:gtk-sharp -r:Mono.Cairo TARGET = HeapBuddy.exe WRAPPER = heap-buddy REPORT_CSFILES = \ @@ -179,6 +179,7 @@ TypeLog.cs \ MethodLog.cs \ MemZone.cs \ + MemGraph.cs \ $(REPORT_CSFILES) bin_SCRIPTS = \ Modified: branches/dmsnell/heap-buddy/analyzer/MemGraph.cs =================================================================== --- branches/dmsnell/heap-buddy/analyzer/MemGraph.cs 2006-07-24 22:54:42 UTC (rev 62934) +++ branches/dmsnell/heap-buddy/analyzer/MemGraph.cs 2006-07-24 23:08:56 UTC (rev 62935) @@ -1,42 +1,71 @@ -// -// MemlogReport.cs -// based on BacktracesReport.cs -// - -// -// BacktracesReport.cs -// -// Copyright (C) 2005 Novell, Inc. -// - -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - using System; using System.Collections; -using System.IO; -using System.Text; +using Cairo; namespace HeapBuddy { - public MemlogReport () : base ("Memgraph") { } + public class Memgraph { + + public class AllocData { + public uint bytes; + + public AllocData () { + bytes = 0; + } + } + + public Memgraph (OutfileReader reader, string data) + { + + DisplayRawData (reader, data); + + } - override public void Run (OutfileReader reader, string [] args) + public void DisplayRawData (OutfileReader reader, string data) { - + int count = 0; + Table table = new Table (); + table.AddHeaders ("Time", "Allocated Bytes"); + + Hashtable Data = new Hashtable (); + AllocData ad; + + foreach (Backtrace bt in reader.Backtraces) { + count++; + if (data != null || bt.Type.Name == data) { + if (Data.Contains (bt.TimeT)) + ad = (AllocData)Data[bt.TimeT]; + else { + ad = new AllocData (); + Data[bt.TimeT] = ad; + } + + ad.bytes += bt.LastObjectStats.AllocatedTotalBytes; + } + } + + uint maxbytes = 0; + uint minbytes = 100000000; + uint avgbytes = 0; + + foreach (DictionaryEntry de in Data) { + uint b = ((AllocData)de.Value).bytes; + + table.AddRow (de.Key, b); + + avgbytes += b; + + if (b < minbytes) + minbytes = b; + else if (b > maxbytes) + maxbytes = b; + } + + Console.WriteLine (table); + Console.WriteLine ("{0} allocations", count); + Console.WriteLine ("Maximum Allocation: {0}", Util.PrettySize (maxbytes)); + Console.WriteLine ("Minimum Allocation: {0}", Util.PrettySize (minbytes)); + Console.WriteLine ("Average Allocation: {0}", Util.PrettySize (avgbytes / Data.Count)); } } } Modified: branches/dmsnell/heap-buddy/analyzer/MemlogReport.cs =================================================================== --- branches/dmsnell/heap-buddy/analyzer/MemlogReport.cs 2006-07-24 22:54:42 UTC (rev 62934) +++ branches/dmsnell/heap-buddy/analyzer/MemlogReport.cs 2006-07-24 23:08:56 UTC (rev 62935) @@ -278,6 +278,13 @@ break; + + case "graph": + Memgraph graph = new Memgraph (reader, "string"); + + break; + + case "/": SetPath ("/"); break; @@ -351,7 +358,11 @@ } } else { - SetPath (arg); + try { + SetPath (arg); + } catch (ArgumentException e) { + + } } PrintMethods (CurrentZone); @@ -373,6 +384,8 @@ try { PrintMethods (CurrentZone); } catch { } + + op = Operand.OP_NONE; break; Modified: branches/dmsnell/heap-buddy/analyzer/OutfileReader.cs =================================================================== --- branches/dmsnell/heap-buddy/analyzer/OutfileReader.cs 2006-07-24 22:54:42 UTC (rev 62934) +++ branches/dmsnell/heap-buddy/analyzer/OutfileReader.cs 2006-07-24 23:08:56 UTC (rev 62935) @@ -431,7 +431,12 @@ private void ReadLogFileChunk_Backtrace (BinaryReader reader) { uint code; - code = reader.ReadUInt32 (); + code = reader.ReadUInt32 (); + + Backtrace backtrace; + backtrace = new Backtrace (code, this); + + backtrace.TimeT = reader.ReadInt64 (); uint type_code; type_code = reader.ReadUInt32 (); @@ -447,9 +452,9 @@ return; } - Backtrace backtrace; - backtrace = new Backtrace (code, this); backtraces [i_backtrace] = backtrace; + + backtrace.Timestamp = Util.ConvertTimeT (backtrace.TimeT); backtrace_codes [i_backtrace] = code; backtrace_type_codes [i_backtrace] = type_code; Modified: branches/dmsnell/heap-buddy/profiler/outfile-writer.c =================================================================== --- branches/dmsnell/heap-buddy/profiler/outfile-writer.c 2006-07-24 22:54:42 UTC (rev 62934) +++ branches/dmsnell/heap-buddy/profiler/outfile-writer.c 2006-07-24 23:08:56 UTC (rev 62935) @@ -209,8 +209,12 @@ } /* Now we can spew out the accountant's context */ + time_t timestamp; + time (×tamp); + write_byte (ofw->out, TAG_CONTEXT); write_pointer (ofw->out, acct); + write_int64 (ofw->out, (gint64)timestamp); write_pointer (ofw->out, acct->klass); write_int16 (ofw->out, frame_count); for (i = 0; acct->backtrace [i] != NULL; ++i) { _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches