iPhone simulator performance

Member
Posts: 21
Joined: 2009.12
Post: #1
okay, I have this simple 2D iPhone game with OpenGL textured sprites. I'm using a basic 60FPS timer, with the assumption that all update/drawing operations should easily be completed within 1/60th of a second, even on first-generation hardware. But after some tests with the simulator, (and reading this thread) I'm now deeply concerned that my App might fail on ANY iPhone.

Graphics consist of the following:
• Background image that continually scrolls from right to left.
• No more than 10 rotating/moving "pill" sprites.
• A character at the bottom that catches the pills in his mouth.

The problem is that I'm getting rather excessive CPU usage. I'm getting 25% on my i7 Mac, which seems absolutely absurd for a scene that literally contains no more than 22 triangles. It doesn't fail, but it definitely causes concern.

For smurfs-and-giggles, I ran it on a hackintosh netbook, and there, it actually did fail to update within 1/60th of a second (so the game looks like it's running in slow motion). I opened up Activity Monitor, and sure enough, the CPU was pegged at 100%.

So, I commented out the scrolling background, and the CPU usage dropped to ~7% on my i7 Mac (maybe that will work). But this background consists of two identical 512x512 sprites placed side by side. When one sprite scrolls completely off the screen, it moves back to the other side, creating a seamless scrolling effect. The bottom line, is that's just 4 triangles. There's certainly going to be a higher fill-rate requirement, but that's on the graphics chip. To the CPU, this should just be 8 vertices when calling something like glDrawArrays(GL_TRIANGLE_STRIP, 0, 4).

So what do you guys think? Am I being paranoid about how this app will run on real hardware? (I'm currently not a registered dev, and I don't currently have an iPhone/iPod touch).

Here's a pic of what I have so far:
[Image: screenshot20100214at253.png]
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
Please read the documentation which has a big huge warning telling you to never assume the simulator reflects the device performance.
Quote this message in a reply
Member
Posts: 21
Joined: 2009.12
Post: #3
Fair enough, but the consensus in that Macrumors thread was that the simulator was always faster, and by no small margin. Some of the phrases being tossed around:
"quite a LOT faster"
"100 times faster"
"much faster"
"exponentially faster"

I understand that Apple says the performance advantage can go either way, but I guess I'd feel more comfortable if I heard at least one report of it going the other way.
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #4
Mister T Wrote:I'm using a basic 60FPS timer, with the assumption that all update/drawing operations should easily be completed within 1/60th of a second, even on first-generation hardware.

No way. Not a chance. The iPhone hardware is not anywhere near powerful enough to make that assumption. Some things you can do that fast, but more often than not, you'll be 45 fps or lower.

Mister T Wrote:I'm getting 25% on my i7 Mac, which seems absolutely absurd...

--> Sim-you-lay-tor <--

I would speculate that it's all software rendered on the simulator, so 25% CPU usage sounds perfectly normal in that case. Heck, when I'm running the simulator on my MacBook, it takes like 50% CPU for mundane stuff sometimes! The same action on the device might only take 10% CPU and that CPU is like only a fraction of the power. So again, there is little point in attempting to extrapolate performance on your Mac to suggest what it might be on the device.

Sometimes things are much faster on the simulator in terms of FPS, yes, but that is largely a useless metric to go by. Get yourself a device to test on!
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #5
Trying to infer the real-world performance of the device from the simulator is completely futile.

Not only are the CPU architectures different (ARM vs Intel) but the graphics rendering pipeline is completely different (tile based deferred renderer vs immediate stream renderer) and you're trying to compare a hardware GPU (MBX or SGX) vs the simulator software renderer.

You'll always be able to create scenarios which are faster on the simulator than the device (glReadPixels and vertex transform are generally very fast in the simulator) as well as the other way around (texture filtering is generally slow in the simulator, and the devices are good at optimizing high-overdraw scenes.)

If you want to know how fast your scene is, test it on the device. End of story.
Quote this message in a reply
Member
Posts: 144
Joined: 2009.11
Post: #6
Mister T Wrote:Fair enough, but the consensus in that Macrumors thread was that the simulator was always faster, and by no small margin. Some of the phrases being tossed around:
"quite a LOT faster"
"100 times faster"
"much faster"
"exponentially faster"

I understand that Apple says the performance advantage can go either way, but I guess I'd feel more comfortable if I heard at least one report of it going the other way.

That's funny, because when I was testing some OpenGL code on the simulator it took my framerate down to that of a powerpoint presentation and then my laptop fan (2008 MB) went into jet-engine mode.

On my 1G iPod touch, worked just fine.

QED, YMMV.

Everyone's favourite forum lurker!
https://github.com/NSError
Quote this message in a reply
Member
Posts: 21
Joined: 2009.12
Post: #7
QED *and* YMMV in one post!! Wink

Seriously tho, I appreciate everyone's input. @cmiller, thank you for your counter-example! I now feel a LOT better about investing in some hardware and joining the dev program.

One last question: Would it be worthwhile for me to try to get my hands on a first-gen iPod touch for testing purposes? With a simple game like this, I don't really care about shaders or intensive graphics. My primary concern is that it runs smoothly on as many iPhones/touches as possible.
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #8
Mister T Wrote:One last question: Would it be worthwhile for me to try to get my hands on a first-gen iPod touch for testing purposes? With a simple game like this, I don't really care about shaders or intensive graphics. My primary concern is that it runs smoothly on as many iPhones/touches as possible.

Yes, first-gen hardware is good to test with if you can get a hold of a device. As far as I've seen, if it works on that, then it works on everything else above it. It also forces you to think in terms of not having newer extras like built-in volume control buttons and speakers, etc. I don't think many of us bother with shader support yet because there simply isn't a large enough base for it yet. Personally I'd give the market a year or two, at least, to flush out old hardware before adding shaders.
Quote this message in a reply
Member
Posts: 21
Joined: 2009.12
Post: #9
Fantastic. eBay, here I come!
Quote this message in a reply
Member
Posts: 144
Joined: 2009.11
Post: #10
AnotherJake Wrote:Yes, first-gen hardware is good to test with if you can get a hold of a device. As far as I've seen, if it works on that, then it works on everything else above it. It also forces you to think in terms of not having newer extras like built-in volume control buttons and speakers, etc. I don't think many of us bother with shader support yet because there simply isn't a large enough base for it yet. Personally I'd give the market a year or two, at least, to flush out old hardware before adding shaders.

I heard somewhere that there was a company that had built literally rack-mount iPhone and iPod touch, for the purpose of remote testing.

But yes, never ever assume that there's a side volume control. I don't have one, and it's always lots of fun to start a game and have bleeding eardrums for a few minutes after I quickly button-mash the home button and start up Music app to turn down the volume.

Everyone's favourite forum lurker!
https://github.com/NSError
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #11
Plus, it's always the users of the lowest common denominator hardware (in any multi-target environment) who are the most vocal in user reviews when something doesn't work great on their device Wink
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Most preferred iPhone simulator? TimMcD 5 3,886 Apr 16, 2010 05:30 PM
Last Post: Chris Burkhardt
  Why do I see strange texture borders on Simulator but not on iPhone? riruilo 2 2,762 Oct 4, 2009 10:33 AM
Last Post: riruilo
  iPhone or Simulator jjslay 2 2,738 Jun 20, 2009 11:42 PM
Last Post: kodex
  iPhone 3.0 slower performance smallstepforman 5 3,702 Jun 18, 2009 11:29 AM
Last Post: kodex
  DEFINEs to know if I'm using simulator or iphone riruilo 2 2,688 Jan 10, 2009 04:19 PM
Last Post: riruilo