Profiling iOS apps?

I am in the process of starting a new project which is a pretty lightweight game engine for iOS, built in Xojo.

I’m trying to determine if there is a way to do actual profiling of performance on a real device (or even in the Simulator). So far it doesn’t look like there is a way to attach Xcode to a running Xojo app, and it doesn’t look like Xojo has profiling support for iOS. Has anyone figured out a way to do this?

I’m concerned mainly because so far the app is causing really high CPU usage when I run it in the simulator – but I don’t know if that’s due to the simulation environment (it’s pretty sluggish all the time honestly), or if it’s the app itself causing this (or more likely, both and to what extent can I do something about it). Any tips or ideas appreciated!

one thing a lot of people either forget or are not aware of …
the iOS simulator is using the power of your Desktop CPU, which in most cases is way more powerful than your average iPhone

So the simulator is a) using a more powerful processor, and b) is in fact a simulator… if that balances out to equal your iPhone or not will be very dependant on what the app is doing at any given second

So it looks like Apple’s Instruments app actually can attach to a running process inside the simulator (and probably on a physical device too, haven’t tried it yet). Only one of the instruments actually worked but it’s enough to see how much CPU is being used from the simulation’s perspective, and how many times each internal API call is made.

A major optimization I was able to make after thinking about it a bit, is to put moving image draws into a second iOSCanvas on top of the background one – then I only invalidate the background canvas if it actually changes. This cuts draw calls by at least 10x in the demo code at least, so I think this will work. I’ve seen references that iOSGraphics/iOSCanvas are just wrappers around CoreGraphics, so I’m guessing this uses CoreGraphics layers to accomplish the separated drawing?

Testing on my physical phone, running the demo code (without the optimization above) used about 6% of my battery after running for 15 minutes. This would mean a play time of around 4 hours, which I think is pretty reasonable actually. So maybe this will work… really trying to avoid the complexity of GL for this because it just isn’t that fancy of a game.

Will do a test with the optimization and see if that helps battery usage drop more (I’m expecting it to…)

Wowz, second test has gone very well… no visible battery percentage drop after running for 15 minutes. Only one object is moving at the moment, but this is pretty fantastic.