Làm cách nào tôi có thể lấy số lượng CPU và tổng RAM từ dòng lệnh OS X?
[email protected]:~$ hwprefs cpu_count
2
[email protected]:~$ hwprefs memory_size
4.00 GB
Bạn có thể lấy cái này từ system_profiler
dụng cụ:
system_profiler SPHardwareDataType | grep " Memory:"
system_profiler SPHardwareDataType | grep Cores:
system_profiler SPHardwareDataType | grep Processors:
hoặc, nếu bạn muốn đi cấp thấp, hãy sử dụng sysctl
:
sysctl hw.memsize
sysctl hw.ncpu
btw, có một loạt những điều thú vị khác mà bạn có thể nhận được từ sysctl
. Thử:
sysctl -a | grep cpu
để xem một vài trong số họ
Các hoạt động sau đây trong OS X Lion:
$ /usr/sbin/system_profiler SPHardwareDataType
Hardware:
Hardware Overview:
Model Name: iMac
Model Identifier: iMac7,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.4 GHz
Number of Processors: 1
Total Number of Cores: 2
L2 Cache: 4 MB
Memory: 4 GB
Bus Speed: 800 MHz