I have a benchmarking program that calculates the time (in milliseconds and ticks), for a persistance to Entity Framework 4.0. Is there a way to calculate CPU load ? I am guessing that I would need to query Windows to find out my CPU frequency, how many cores, etc. Does this sound right ? If so, what part of the .NET framework relates to querying the system ? I am guessing System.Diagnostics ?
Thanks,
Scott
You can use a PerformanceCounter (for the System load).
Or, better:
You will have to relate that to wall-time to get a percentage. Also see UserProcessorTime.
Edit:
On second thought, if you want to benchmark wouldn’t you rather measure just elapsed time from executing a piece of code, eg the System.Diagnostics.Stopwatch class?