LogDump: CLRProfiler Log analysis tool

Ever wonder how I produce nice textual allocation summaries like this one?

This report shows allocations in dictread.log

Total Allocations 136301 Objects 6694232 Bytes

Top 10 Allocated Types

   Count Bytes Type
108040 5836392 System.String
26726 534520 DictionaryEntry
73 275604 System.Object []
1010 20200 System.Text.StringBuilder
51 10466 System.Char []
11 6358 System.Byte []
53 1272 System.Collections.ArrayList
52 1248 ArrayListEnumeratorSimple
6 1008 bucket []
18 504 System.Security.SecurityElement

Top 10 Allocating Stacks

Stack 1 allocates 3132656 bytes
NS.Test::Main static void (String[])
Dictionary::.ctor void ()
DictionaryEntry::Parse static DictionaryEntry (String)
System.String::Substring String (int32 int32)
80178 3132656 System.String

Stack 2 allocates 2402768 bytes
NS.Test::Main static void (String[])
Dictionary::.ctor void ()
System.IO.StreamReader::ReadLine String ()
25723 2382668 System.String
1005 20100 System.Text.StringBuilder

Stack 3 allocates 534520 bytes
NS.Test::Main static void (String[])
Dictionary::.ctor void ()
DictionaryEntry::Parse static DictionaryEntry (String)
26726 534520 DictionaryEntry

That's a report similar to the one that I generated for Performance Quiz #6 -- I get a ton of mileage out of these.  Just use CLRProfiler for Beta2 or greater, save your .log files and run this little tool over it to get a summary of the total costs and their major sources.  This little guy saves me a ton of time and I've used it to anlayze multi-gigabyte log files where the UI approach just isn't going to work.  The algorithm is to just attribute each allocation to a callstack and then compute the callstacks with the biggest cost -- which is basically the same as going into the tree view in the UI and opening the biggest choice at each step, then 2nd biggest etc.

I've just posted the source code for this little dumper -- it's a quickie I wrote one afternoon and it shows -- but hopefully you can get some good usage out of it as well.

Legal Note: Like all other code samples this program is offered AS IS with no warranty implied and confers no rights .