I'm working on an iPhone project with a buddy, and the progress has been slow-ish going so far. Our biggest problem is committing to an idea; we have a good number of them, however we haven't found a gameplay combination we're fully ready to jump on. I feel like we're getting closer though, we've done a good job of bouncing new ideas around and trying to prototype stuff out.
While we're figuring out gameplay, I'm working on creating some generic utilities to assist us in development and iteration. One item that comes to mind is a search method I wrote several weeks ago. It provides a nice API method for finding a specific object by a name within a hierarchy of objects in the game scene. This method (call it FindGameObject) worked fairly well, however I found some limitations to it which I knew would cause a slowdown on the iPhone given the number unnecessary operations I was doing. Tonight I decided to trim this down to make it leaner and meaner with some ideas I came up with.
First thing I did was write a test script to provide profiling support and get a baseline of how much time it took to run 10 million searches using FindGameObject on a deep heirarchy (about 8 objects). I decided on 10 million somewhat randomly, however it was deliberately a large number to enhance the visible impact of small changes. Then I wrote the new version of my method (call it FindGameObject2) with my new changes and hooked it into the test script. The results were:
FindGameObject - Took: 6.948123 sec to run 1000000 lookups
FindGameObject2 - Took: 5.916583 sec to run 1000000 lookups
This is a rough average of about 5 runs, not a scientifically acceptable test set but good enough for our purposes. Comparing against the current functionality, you can see I gain ~1 second when doing 10 million lookups, which is about a 15% increase
Before I finish I must mention these tests were run on my PC dev machine, not the actual iPhone hardware. This makes it especially important to possess a test case I can reliably run on the iPhone hardware, so I can compare my changes against the original functionality on the target hardware. However I expect my optimizations to yield a comparable speed increase on the iPhone hardware.