I know that CPUs count all L1/2/3 cache misses, and this info is accessible in principle. E.g. there is a performance viewer from Intel. I just cannot find an example in C#. Is this data accessible from .NET?
Well you can do this (on windows at least) using Intel Perfomance Counter Monitor. In addition to other tools which come bundled with it, it contains PCM-Service - windows service which adds PCM windows perfomance counters. Once you downloaded, compiled and installed this service, you can access L2 cache misses (for example), as easy as this:
var pc = new PerformanceCounter("PCM Core Counters", "L2 Cache Misses", "total_"); // instead of total_ you can use number of core
var value = pc.RawValue; // or pc.NextValue() and so on.
Intel PCM adds much more interesting counters than just cache misses of course, all of which are accessible from .NET.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With