I would like to have a function that returns the processor speed of an iOS device.
I found what I thought might be a solution with this:
#include <CoreService/CoreService.h>
long getProcessorClockSpeed()
{
OSErr err;
long result;
err=Gestalt(gestaltProcClkSpeed,&result);
if (err!=nil)
return 0;
else
return result;
}
but this doesn't compile. (CoreService.h file not found). Apparently, this is for Mac OS and not iOS?
I have written and optimized a signal processing algorithm that can now just barely run in real time on an iPhone 4S. I would like to allow the algorithm to run on dual-core devices with a clock speed of 800 MHz or more, and disallow it on other devices. I am already able to get the number of cores, but I have not been able to get the CPU clock speed.
I could do something like get the model of the device, and then allow or disallow the algorithm on devices based on that string, but that kind of table-based approach would need to be updated as new devices become available or would impose assumptions about new devices.
Is there an idiomatic way for getting the CPU clock speed?
Kudos awarded for: 1) an approach that won't get my app rejected 2) an approach that is less headache than a model-name-table-based approach?