I am aware of these answers:
Which refer to
Intel Power Gadget as a way to obtain current CPU frequency, is there a program/method to obtain this information from the terminal?
sysctl hw.cpufrequency only shows the nominal frequency of the CPU, i.e. what the manufacturer has stated. It does not consider Turbo Boost or lower frequencies when CPU is idle. (For example if CPU is i5, 1.4GHz, it will always state 1.4GHz)
C solution given it SO using
sysctl.h has the same effect.