Compiler Comparison: GCC 4.7 vs CLang 3.1 on eddic
The first thing that I tested has been the compilation time of the two compilers to compile eddic with different flags. I tested the compilation in debug mode and with -O2 and -O3.
The most interesting fact in these results is that CLang is much faster than GCC. It takes twice less times to compile eddic with CLang in debug mode than with GCC. The impact on optimizations on CLang’s compilation is also more important than on GCC. For both compilers, -O3 does not seems to add a lot of overhead.
Then, I tested the performances of the generated executable. I tested it on three things, the whole test suite and two test cases that I know are the slowest for the EDDI Compiler. For each case, I took the slowest value of 5 consecutive executions.
The difference are very small. In -02, GCC performs a bit better, but in -O3, the performances are equivalent. I was a bit disappointed by the results, because I thought that there would be higher differences. It seems that CLang is not as far from GCC that some people would like to say. It also certainly depends on the program being compiled.
It is clear that CLang is much faster than GCC to compile eddic. Moreover, the performances of the generated executable are very similar.
I will continue to use CLang as my development compiler and switches between the two when I’m doing performances benchmarking. I will try to update the benchmark once new versions of GCC / CLang are available.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)