1.3 C
Sunday, March 3, 2024

Is there a strategy to see present CPU frequency in macOS from terminal (not Intel energy gadget)

sudo powermetrics will show data that tells you about your core clock frequency. The output may be very completely different between Intel and ARM processors.

Plainly on Intel processors the precise clock frequency stays unchanged, however the CPUs might be unused some a part of the time. So you may have output like

 CPU Common frequency as fraction of nominal: 85.40% (1964.20 Mhz)

which implies your CPU runs at 2,300 MHz, however solely 85.40% of the time. And that’s reported for every particular person CPU. I do not know what occurs in a “turbo” mode the place the clock pace ought to supposedly be increased, or if the clock pace goes down if the pc will get too scorching.

An M1 or M2 processors has completely different output. On an M1 Professional, the eight efficiency cores can every run at 15 completely different speeds from 600 MHz to three,328 MHz; effectivity cores have 4 speeds from 600 MHz to 2,064 MHz. The instrument experiences for every core what share of time it spent at which clock pace. And every processor could be idle; as a kind this, complete idle time is about 796% for the efficiency cores, so they’re solely used 4% of the time.

So on this case you could have eight cores, every able to operating at 3,328. Your resolution is now what you name the clock pace. You can name it 3,328 MHz till you get all cores operating and possibly the clock pace goes down a bit as a result of warmth.

Now programmatically: This instrument is sudo solely, so you may’t simply launch it from an app. On an M1 Professional, you should use clock_gettime_nsec_mp (CLOCK_THREAD_CPUTIME_ID) to get the time within the present thread with a decision of 42 nanoseconds on that individual processor (sooner and better decision than clock()). Then you definitely write a loop that runs for instance 1,000,000 iterations of a loop with 1 cycle per clock, measure the time, and calculate the clock pace from that. clock_gettime_nsec_mp is kind of secure, so three measurements and throwing away the worst outlier must be high quality. It could be a bit tough to jot down a loop that does not get fully optimised away 🙂

In order for you Intel clock speeds as nicely, chances are you’ll want a unique loop, and test what number of cycles it takes. And you need to distinguish which processor is used, and keep away from utilizing Rosetta as a result of Rosetta runs ARM code however thinks it’s operating on Intel.

Latest news
Related news


Please enter your comment!
Please enter your name here