Platinum Partner
architects,high-perf,c & c++,gcc,clang,comparison guide,compilers,eddic

Compiler Comparison: GCC 4.7 vs CLang 3.1 on eddic

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 {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}