View Full Version : GCC 4.2 (iPhone SDK) Performance

Jun 16, 2008, 05:51 PM
I was running some simple compiler performance tests and thought I'd share. These tests are run on a Core2 Duo MBP, OS X 10.5.3, using GCC 4.0.2 (normal updated dev tools install) and 4.2 (comes with iPhone SDK)

For this test, I have a simple insult generator program which can benchmark itself by timing how long it takes to generate 2 million insults. The generator traverses sentence structures filling in tokens with appropriate word types from arrays. The only external function called during generation is rand() a few times. This is pretty optimized straight-C code... easy compiling.

Anyways, on to the tests. I ran the test a few times and took the average time (it was generally very consistent). First, I did all with -O3 -mtune=nocona (core2 arch is only in GCC 4.2):

gcc4: 0.697 seconds
gcc-4.2: 0.779 seconds

For kicks, here's the same code built with g++4 (C++ compiler):
g++: 0.724 seconds

Here's the results when using -mtune=core2 on gcc-4.2:
0.819 seconds

In short, gcc 4.2 is apparently not yet ready for prime time. Even using the actual system arch, which is, strangely, slower than the P4 nocona arch, its around 10% slower than gcc 4.0.2. This isn't terrible, but seeing an Apple GCC4 that finally has core2 arch support got my hopes up, and I was let down. Just thought I'd share.