The internet is just incredible. Within 30 minutes of logging onto the #iphonedev IRC channel on freenode, I got timing results for the iPhone on the simple loop benchmark from my last post. Thanks to ‘august’ for the help.
Here’s the benchmark converted into objective-C:
NSDate *start = [NSDate date];
for(int i = 0; i < (8*320*480); i++)
arr[i] = i;
NSDate *end = [NSDate date];
NSLog(@"%g", [end timeIntervalSinceDate:start]);
- iPhone (2.1 firmware, Objective-C): 9.5 milliseconds
And, from last time:
- G1 (R29 firmware): 922 milliseconds.
- G1 (R29 firmware): Loop only. 520 milliseconds.
Objective-C kills the Java implementation on Android. It’s almost exactly 100 times faster. Note that I’m unsure if the memory allocation is included in the timing, so a more conservative statement is that Objective-C can run a tight loop 50 times faster than the Dalvik JVM. It’s also true that real applications aren’t full of tight loops, and a real Android application won’t be 50 times slower than an iPhone counterpart. Nevertheless, all else being equal, it will be slower, and potentially a lot slower.
For now, we’re sadly going to put our Android development on hold and switch to iPhone, and keep an eye out for performance improvements.