views:

87

answers:

3

Edit: I'm NOT asking for a way to implement a profiling library, I'm asking if there's one (preferably free) out there.

Although there are a lot of commercial and free profilers for the .NET platform they all analyses (better or worse) your application code in a way that let's you see what method call or even line is consuming a lot of resource.

While that might be useful in a lot of quick optimization situations I was interested in a more direct "library" approach. Basically I have in mind something that lets me define scenarios with checkpoints so that I can profile and compare between versions any two given scenarios.

I want to be able to define something like:

Mon.StartScenario("ClientReportsTime");
// Get All clients
//...
Mon.CheckPoint(); // You should be able to see memory ussage 
                 //and time taken to reach this point.
// Extract information
//..
Mon.CheckPoint();
// Finished!!
Mon.StopScenario("ClientReportsTime");

So that an scenario has a given time that can be precisely identified. It's a relatively simple piece of functionality and I was about to implement it as a library when I thought that might be out there somewhere. Do you know about some existing library like that?

+1  A: 

You could look at the Process info for your own app, and perhaps record more info from WMI.

Unfortunately, it does not really give you much to go on :(

leppie
I could implement it myself, I don't have any problem with that. As this are library calls its relatively straight forward to get all the information that you need, specially with that syntax... the things is I don't want to reinvent the wheel if something similar already exists (or if the SO community things that is a bad idea anyay)
Jorge Córdoba
I cant remember seeing anything of the top of my head, but I have written little micro versions quite a few times. It all depends what info you are interest in.
leppie
Anyways, it looks like something that would be handy in a unit testing library, perhaps one of them offers something similar already.
leppie
+1  A: 

What about using Performance Counters? That would work, as you define a Performance Counter for the scenario, and then use the available methods (such as Increment, IncrementBy, etc.) to record the checkpoints. For more info see: http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter(lightweight).aspx.

Schmuli
+1  A: 

If you had a choice between

  1. Something that would give you precise timing of problems but only imprecisely locate them, or

  2. Something that would give you precise location of problems but only imprecisely time them,

which would you prefer?

This method does the latter.

Mike Dunlavey