Performance Zone is brought to you in partnership with:

I’m a swiss Master student in Computer Science. I’m very interested in C++, open source projects, Linux, Intel Assembly and Agile. I'm currently working on Eddi, a new programming language that I created to improve my skills in C++. I've also worked a lot on Java technologies (Sprint, Osgi, Play!, ...), but I'm not currently working with Java anymore. Baptiste is a DZone MVB and is not an employee of DZone and has posted 51 posts at DZone. You can read more from them at their website. View Full User Profile

Compiler Comparison: GCC 4.7 vs CLang 3.1 on eddic

11.13.2012
| 4772 views |
  • submit to reddit
Now that eddic can be compiled with CLang, I wanted to compare the differences in compilation time and in performances of the generated executable between those two compilers. The tests are done using GCC 4.7.2 and CLang 3.1 on Gentoo.

Compilation Time

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.

dyerware.com


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.

Runtime performances

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.

dyerware.com


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.

Conclusion

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.

Published at DZone with permission of Baptiste Wicht, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)