I'm experimenting with different ways to do game graphics in WinRT, and it'd be nice if my test app could measure and display its own CPU usage, so I could compare different approaches (ItemsControl vs. manually moving Images around vs. DirectX).
In full-fledged .NET, I can read Process.TotalProcessorTime at two known points in time, and then take the delta processor time divided by the delta time (adjusted for number of processors if necessary). If the app is running in full-trust, I can even find the Process instance for dwm.exe (since it does all the heavy lifting of putting the GUI on the screen) and add that into my CPU time. This is the approach I took in the WinForms and WPF versions of my Game Graphics test suite.
But in WinRT, the System.Diagnostics.Process class does not exist. If there's an alternate API, I'm not sure where to look for it.
I can open Task Manager and set it to stay on top, and just keep an eye on it as my app runs. This is less than ideal, since (a) it covers part of my window, and therefore probably skews the results slightly; and (b) I can't do any of my own aggregation or logging of the results (e.g. "here was the average CPU usage over a ten-second span"). So if there's some way I could get my CPU usage programmatically, I'd prefer that, just because of the added flexibility it gives me.
Is there any way for a WinRT app to determine its own CPU usage?