iPhone Property-List Benchmark
Researching the best way to solve a problem, I decided to write a quick benchmark.
The issue involves a complex many-levelled hierarchical dictionary (+20k when stored in XML format), and I wanted to know if crawling it looking for specific keys would be too slow to be viable. My test function crawls the dictionary, and looks for keys that exist (4), and some that don’t (6). I repeat the process 1000 times, for luck.
I wrote the initial test as a command-line app to run on the Mac. Mostly because testing is quicker when you don’t have to deploy to a device. It’s a 2.66Ghz Core 2 Duo.
found 4000 of the 10000 keys in 0.763134 seconds
Then I added my code to a template view-based application for iPhone, and tested in the simulator.
found 4000 of the 10000 keys in 1.249594 seconds
Then I tested on-device (not in debug mode). It’s a 16gb iPhone 4, for the record.
found 4000 of the 10000 keys in 14.157210 seconds
That means Mac : Simulator : iPhone has a speed ratio of 1 : 1.6 : 18.6. Obviously this is not going to be a hard and fast rule, but for this type of operation it seems like a useful rule-of-thumb.
I will probably dig out the rest of my testing suite (iPad 2, iPad 1, 1st Gen iPod Touch, iPhone 3GS) to fill out these stats. I will update this post when I do. For now my question has been answered: yes, this solution will work.