问题
This used to work in iOS 5 but does not seem to work any longer:
unsigned freq;
mib[0] = CTL_HW;
mib[1] = HW_CPU_FREQ;
sysctl (mib, 2, &freq, (void*) &len, NULL, 0);
Does anybody know an alternative?
Thanks.
回答1:
Apple doesn't provide the CPU frequency for all hardware. For example, it was unknown for some time exactly what the clock rate for the A4 in the iPod touch 4g was.
I think the best you can do is determine what the device is, and construct a lookup table with the CPU frequencies you can find on wikipedia and so on. Then, if you can't probe the CPU frequency, look it up in the lookup table.
来源:https://stackoverflow.com/questions/8291357/cannot-get-cpu-frequency-in-ios-5