开发者

Detecting iPad processor/performance

开发者 https://www.devze.com 2023-04-05 02:34 出处:网络
I have an OpenGL ES2-based app which runs smoothly at 30fps on an iPad 2, but on an iPad 1 it\'s a bit jerky.I want to modify my app to use a def开发者_如何学运维ault frame rate of 20fps on the iPad 1

I have an OpenGL ES2-based app which runs smoothly at 30fps on an iPad 2, but on an iPad 1 it's a bit jerky. I want to modify my app to use a def开发者_如何学运维ault frame rate of 20fps on the iPad 1, which I've already verified makes it feel much smoother on that model.

What's a good way to detect the iPad 1's lower performance? Should I just look for more than one CPU core (and how do I detect that) or maybe the processor speed or total system memory? I know it's bad to look at device strings so I'm avoiding that. I've considered having my drawing code simply detect that it isn't keeping up with the frame rate and throttling it back, but that has complications I'd rather avoid (ie, falling back on an iPad 2 just because of a transient load spike, then having to add even more code to re-try the higher frame rate just in case that happens).


Maybe you should try sysctl for this.

- (NSUInteger) getSysInfo: (uint) typeSpecifier
{
    size_t size = sizeof(int);
    int results;
    int mib[2] = {CTL_HW, typeSpecifier};
    sysctl(mib, 2, &results, &size, NULL, 0);
    return (NSUInteger) results;
}

- (NSUInteger) cpuFrequency
{
    return [self getSysInfo:HW_CPU_FREQ];
}

- (NSUInteger) busFrequency
{
    return [self getSysInfo:HW_BUS_FREQ];
}

See Erica Sadun's UIDevice+Extension category (from which this code is extracted).


Did you look at the displayLinkWithTarget:selector: method of UIScreen and the associated CADisplayLink class?

I personally never used it, but it seems to be the solution to synchronize your framerate with the refresh rate of the screen. This way you will be able to adapt your framerate to its ideal value, and update your display only when necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号