Reputation: 18343
I'm running win10 on the raspberry pi 2. Using C# (and universal apps), I'm wondering if there is a way to get cpu usage or memory usage?
my guess is 'no' as I don't seem to have access to PerformanceCounters, but perhaps there is a hack that i'm not yet aware of?
Upvotes: 4
Views: 1169
Reputation: 218
You can access the data used by the webpage mentioned by sending a HTTP GET request on port 80 to http://[yourpi]/api/resourcemanager/systemperf. This will return you a block of JSON. This is documented on the device at http://[yourpi]/restdocumentation.htm.
P/Invoke of GetNativeSystemInfo failed on my IoT device. The error indicated that it couldn't find kernel32.dll. The same code worked as expected on my Win10 desktop.
I will ask the product group about accessing performance data programmatically.
Mark Radbourne (MSFT)
Upvotes: 2
Reputation: 7385
I don't know if it is working, but you could give GetNativeSystemInfo
a try.
[StructLayout(LayoutKind.Sequential)]
internal struct SYSTEM_INFO
{
public ushort wProcessorArchitecture;
public ushort wReserved;
public uint dwPageSize;
public IntPtr lpMinimumApplicationAddress;
public IntPtr lpMaximumApplicationAddress;
public UIntPtr dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public ushort wProcessorLevel;
public ushort wProcessorRevision;
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
internal static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSystemInfo);
Details can be found here: msdn
Upvotes: 0
Reputation: 47
By default, a HTTP Server is running on Port 80 of the RPi2 with W10. Just open your webbrowser, type in your RPi's IP, login and click on Performance (http://raspberrypi/SystemPerformance.htm). There you go! If you'ld like to generate a Performance Profile, go to Perf-Tracing (http://raspberrypi/xperf.htm).
Upvotes: 0