I'd like to programmatically get the CPU descriptions on Mac OS X, which look something like this:
Intel(R) Core(TM)2 CPU 6700 @ 2.66GHz
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
On Linux you can do grep "^model name" /proc/cpuinfo
and on Windows you can look at the ProcessorNameString
value in HKLM\Hardware\Description\System\CentralProcessor\0
in the registry, but how do you get that information on OS X?
In the menu, select “Dock Icon,” and you will see several options. For now, select “Show CPU Usage.” With “Show CPU Usage” turned on, Activity Monitor's dock icon will transform into a 10-segment gauge that lights up, depending on how much CPU activity is taking place.
Check if the discrete or integrated GPU is in use To see which graphics cards are in use, choose Apple () menu > About this Mac. The graphics cards currently in use appear next to Graphics. Learn which integrated GPUs your Mac might have.
You can pass machdep.cpu.brand_string
to sysctl to retrieve the string you're looking for.
[ben@imac ~]$ sysctl machdep.cpu.brand_string
machdep.cpu.brand_string: Intel(R) Core(TM) i5-2400S CPU @ 2.50GHz
The same information is exposed through the sysctl(3)
functions.
[ben@imac ~]$ cat sys.c
#include <sys/types.h>
#include <sys/sysctl.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
char buf[100];
size_t buflen = 100;
sysctlbyname("machdep.cpu.brand_string", &buf, &buflen, NULL, 0);
printf("%s\n", buf);
}
[ben@imac ~]$ ./sys
Intel(R) Core(TM) i5-2400S CPU @ 2.50GHz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With