Last active
June 14, 2021 08:42
-
-
Save chockenberry/2afe4d0f1f9caddc81de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the next version of iPulse, I'd like to show GPU statistics. Unfortunately, the format | |
for these statistics is vendor specfic (see the "Performance Statistics" dictionary below.) | |
In order to cover as many devices as possible, I'd like you to run the following commands | |
from your Terminal: | |
$ sysctl hw.model | |
$ ioreg -r -d 1 -w 0 -c "IOAccelerator" | |
You can help me read the results by putting them in a code block (triple backticks). | |
I'll add a few of my Macs to get this list started. Thanks for your help! |
Here is the code I landed on:
NSNumber *gpuUtilization = nil;
if (performanceProperties[@"Device Utilization %"]) {
// chockenberry
// iMac15,1 - AMDRadeonX4000
// alanhussey
// MacBookPro11,3 - GeForce
// MacBookPro11,3 - AppleIntelHD5000Graphics
// poreed
// MacBookPro8,2 - AMDRadeonX3000
// tkrajacic
// MacBookPro10,1 - GeForce
// MacBookPro10,1 - AppleIntelHD4000Graphics
// therayjay
// Macmini6,2 - AppleIntelHD4000Graphics
// hotchkiss
// MacbookPro11,5 - AMDRadeonX4000
// MacbookPro11,5 - AppleIntelHD5000Graphics
// owlboy
// iMac12,2 - AMDRadeonX3000
// bmike
// MacBook8,1 - AppleIntelBDWGraphics
// chrisbulow
// MacBookPro11,1 - AppleIntelHD5000Graphics
// eportlance
// iMac12,2 - AMDRadeonX3000
// bmike
// Macmini6,2 - AppleIntelHD4000Graphics
// bmike
// MacPro6,1 - AMDRadeonX4000
// MacPro6,1 - AMDRadeonX4000
// eportlance
// MacBookPro12,1 - AppleIntelBDWGraphics
// msealand
// iMac13,2 - GeForce
// samsonjs
// iMac15,1 - AMDRadeonX4000
// iMac15,1 - AppleIntelHD5000Graphics
// bmike
// MacBookPro10,2
// JackoPlane
// iMac13,2 - AppleIntelHD4000Graphics
gpuUtilization = performanceProperties[@"Device Utilization %"];
}
else if (performanceProperties[@"GPU Core Utilization"]) {
// chockenberry
// MacPro4,1 - GeForceTesla
// MacPro4,1 - GeForceTesla
// alanhussey
// MacBookPro11,3 (value = 120000000)
// thejayray
// Macmini4,1 - GeForceTesla
// samsonjs
// MacBookPro6,2 - GeForceTesla
// ender3
// Macmini3,1 - GeForce
// bmike
// iMac13,2 - GeForce
// msealand
// iMac13,2 - GeForce (value = 0)
// JackoPLane
// iMac13,2 - GeForce (value = 60000000)
gpuUtilization = performanceProperties[@"GPU Core Utilization"];
}
else {
// no GPU statistics
// IntelHD3000
// chockenberry
// MacBookAir4,2 - AppleIntelHD3000Graphics
// poreed
// MacBookPro8,2 - AppleIntelHD3000Graphics
// tobiasmboelz
// iMac11,1 - ATIRadeonX2000
// owlboy
// iMac12,2 - AppleIntelHD3000Graphics
// commandtab
// MacBookPro11,2 - AppleIntelHD5000Graphics (???)
// owlboy
// Macmini5,1 - AppleIntelHD3000Graphics
// eportelance
// iMac12,2 - AppleIntelHD3000Graphics
// bmike
// Macmini5,3 - AppleIntelHD3000Graphics
// samsonjs
// MacBook1,1 - AppleIntelGMA950
// bmike
// iMac13,2 - AppleIntelHD4000Graphics
}
if (gpuUtilization) {
long rawGpuUtilization = gpuUtilization.longValue;
if (rawGpuUtilization > 100) {
rawGpuUtilization = rawGpuUtilization / 10000000; // scale down "GPU Core Utilization"
}
...
Thank you so much!
This is almost exactly what I've landed on as well. Turns out some newer GPU drivers also have a property called "GPU Activity(%)" which is pretty much the same as "Device Utilization %".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Were you ever able to calculate GPU processor usage % for GPU drivers that don't have the properties 'Device Utilization %' or 'GPU Core Utilization'?