I'm looking to sample the hardware event "instructions retired" or "exclusive instructions retired" from an intel chip from a C# application.
Specifically, I need to sample this number at the beginning and end of a function call, so running a profiling run using cpu counters in visual studio 2010 according to this article:
http://msdn.microsoft.com/en-us/library/bb385772.aspx
does not help. Using CPU counters and running a sampling profile, you can get the total # of instructions retired for your entire application. I can't re-assembly this application to only call just this function, so i need to be more specific about the "start" and "end" of this instructions retired sample.
Does anyone know of some assembly instruction that will read the instructions retired hardware event? Presumably, if this was available, I could somehow call this assembly instruction directly from the beginning and end of my C# method.