简体   繁体   中英

Windows Xbox JavaScript UWP APP get CPU/Memory Usage

Developing a JavaScript UWP app on Xbox and I would like to know how can I get CPU and memory usage information

I found this API, Windows.System.Diagnostics.ProcessCpuUsage

but the getReport method is not defined as claimed by Microsoft documentation

https://docs.microsoft.com/en-us/uwp/api/windows.system.diagnostics.processcpuusage

Any help would be greatly appreciated

With the Windows 10 Fall Creators Update 1709 (build 16299 and later) we have added a number of new diagnostics APIs to the UWP API surface to support scenarios like this. Please be sure to install and target the SDK version 16299 (or later). Here is a related blog post:

https://blogs.windows.com/buildingapps/2017/06/28/uwp-app-diagnostics/

I thought I'd add a quick code snippet here to reflect the JavaScript part of the question:

Keep in mind this is only here as a jump-start for anyone trying to get a memory report for your app as it's running from within JS. This is only example code and not terribly fault-tolerant.

 Windows.System.AppDiagnosticInfo.requestInfoAsync().then((allProc) => { let proc = allProc[0]; let allGroups = proc.getResourceGroups(); let procGroup = allGroups[0]; let memReport = procGroup.getMemoryReport(); console.log(memReport); console.log( ` [${memReport.commitUsageLevel}] : commitUsageLevel \\n` + ` [${memReport.commitUsageLimit}] : commitUsageLimit \\n` + ` [${memReport.privateCommitUsage}] : privateCommitUsage \\n` + ` [${memReport.totalCommitUsage}] : totalCommitUsage \\n` ) }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM