Timestamps with allocs and graph beginnings

svn path=/branches/dmsnell/heap-buddy/; revision=62935
This commit is contained in:
dsnell 2006-07-24 23:08:56 +00:00
Родитель ddda018d49
Коммит 6f17ab716c
6 изменённых файлов: 93 добавлений и 38 удалений

Просмотреть файл

@ -29,6 +29,9 @@ namespace HeapBuddy {
public Type Type;
public int LastGeneration;
public long TimeT;
public DateTime Timestamp;
public ObjectStats LastObjectStats;

Просмотреть файл

@ -154,7 +154,7 @@ sharedstatedir = ${prefix}/com
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 @@ CSFILES = \
TypeLog.cs \
MethodLog.cs \
MemZone.cs \
MemGraph.cs \
$(REPORT_CSFILES)
bin_SCRIPTS = \

Просмотреть файл

@ -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") { }
override public void Run (OutfileReader reader, string [] args)
{
public class Memgraph {
public class AllocData {
public uint bytes;
public AllocData () {
bytes = 0;
}
}
public Memgraph (OutfileReader reader, string data)
{
DisplayRawData (reader, data);
}
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));
}
}
}

Просмотреть файл

@ -278,6 +278,13 @@ namespace HeapBuddy {
break;
case "graph":
Memgraph graph = new Memgraph (reader, "string");
break;
case "/":
SetPath ("/");
break;
@ -351,7 +358,11 @@ namespace HeapBuddy {
}
} else {
SetPath (arg);
try {
SetPath (arg);
} catch (ArgumentException e) {
}
}
PrintMethods (CurrentZone);
@ -373,6 +384,8 @@ namespace HeapBuddy {
try {
PrintMethods (CurrentZone);
} catch { }
op = Operand.OP_NONE;
break;

Просмотреть файл

@ -431,7 +431,12 @@ namespace HeapBuddy {
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 @@ namespace HeapBuddy {
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;

Просмотреть файл

@ -209,8 +209,12 @@ outfile_writer_add_accountant (OutfileWriter *ofw,
}
/* Now we can spew out the accountant's context */
time_t timestamp;
time (&timestamp);
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) {