.NET Framework - I want to write my own profiler

Asked By not_a_commie on 01-Jun-07 03:27 PM
I want to write myself a simple profiler. It would run a .NET
application and wait for the application to exit. When it exits I want
to see a grid containing 1) fully-qualified method/property name, 2)
the number of times it was called, 3) the amount of CPU time spent in
that function.

I can start a process, but I'm unsure what to look for. Is there some
global output pipe that .NET applications allow other applications to
hook into? How does that work? How does Visual Studio monitor all the
managed modules that were loaded when you execute in debug mode?

Aneesh P replied on 01-Jun-07 04:07 PM
I think you can find out the assembly references and associated method
references. Use some counting mechanism for these references. I'm not
sure how the execution breaks down into countable blocks. Probably we
can use a dictionary to store the assembly name and the count.
Chris Mullins [MVP] replied on 01-Jun-07 06:45 PM
There are alot of resources on the web to help you get started with this:

Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP