views:

547

answers:

2

I have a feeling I may already know the answer to this question, but I'll ask it anyway.

Are there any better ways of using the .Net Profiling API than the COM/Managed C++ route?

My reluctance to follow the suggested COM approach is as such:

  • Effort, it's a lot of legwork to get started
  • Don't like the magic involved in hooking up the C++ dlls, not easy to redistribute with projects
  • Feels hard to unit test
  • Don't want to behavior in C++. I could create an interop layer, but that's even more work
  • Hard to debug. From what I've gathered you can't attach a debugger to the actual C++ layer, so you're back to log files and such

I came across a project called NProf, which was an attempt to wrap the API with a managed layer. Unfortunately it hasn't been updated since 2003.

Does anyone have any leads that might help? This all just feels a bit nasty.

Clarifications:

  • This describes the API I'm referring to: The Profiling API
  • I'm using Visual Studio 2008, and v3.5 of the framework
A: 

Profiling is a very low level and performance sensitive area, hence it is exposed as a low level API. I think this just comes with the territory for this kind of functionality.

Can you elaborate on the debug issue ... you should be able to attach an unmanaged debugger to the managed executable you are profiling and use that to debug your profiler dll.

Rob Walker
The debugging issue is just hearsey. I've yet to start any work and I just read on my travels that it's difficult to debug the unmanaged side of things. If it's not, then that's great.
James Gregory
See my comment above for how to debug the in-proc C++ profiler code.
Omer Raviv
+2  A: 

You can take a look at Part-Cover. It's a code coverage tool (GPL) but it works similarly to NCover, which means it uses profiling API to do its job. Not sure how good or bad the code is, and of how much help it'll be for you (GPL may be an issue as well), but its something you may want to take a look at. It's been updated late last year and then went silent, so I'm not sure if the project is still active.

Krzysztof Koźmic
Thanks, I'll check the license and see what it permits me to do.
James Gregory