I want to find the most efficient way to access the CLR performance counters in-process (e.g. ".NET CLR Memory" or ".NET CLR Jit"). I use the CLR Profiling API, so I can do this natively (preferred), but also managed if necessary.
I do know, I can use PDH.dll to query perfcounters natively. However I am trying to avoid PDH.dll, since it has numerous drawbacks and quirks (instance-index handling, translation, permissions, ...).
My real question is, is there a way to get to the CLR metrics data-structures directly in-memory and read them as they are (without going through the perfcounter API)? When studying the Shared Source CLR, I found perfcounterdefs.h, which contains all of these data structures. Is there a way to get there directly? Should I even consider this direction, or will I drive straight to hell, when I get my hands on internal data structures?
Thanks,
-Christoph