0

I've got some old C files, written in 1999 for the older. There are some useless parts of the code because of new programming techniques. But I've got a problem.

  • The original file => 640 lines --> 0.448 seconds
  • The new file => 581 lines --> 0.493 seconds

I have to use Intel C++ Compiler Version 10 with O3 optimisations. The compiler configuration is not customizable except options and flags in the compilation line.

This difference of time between the original and the new file could be insignificant, but when extrapolated to 5000 files, it adds up.

I don't think it is the fault of the compiler.

EDIT FOR CLARIFICATION

I have to optimize the compilation time of lots of C files. These files contain lots of old code that it is useless (#if 0, preprocessor code...). In order to remove all those things, I created a Python script that examines all of files and removes all undesirable pieces of code.

The patch works really well. It removes all the code I want. But the compilation time increases. I don't understand why.

EDIT #2

My patch removes only part of code which is removed by the preprocessor like #if 0, and merging loops. 15 loops with one line and the same max is worst than 1 loop with 15 lines inside. I made lots of tests on big file (70000 lines) and I save 60% of the original compilation time. I don't add complexity or other operations. It's a code purge.

CloudCompany
  • 357
  • 3
  • 15
  • Not sure what your question is, but either way is the time difference that significant even with 5000 files. In your example: Original file 37m 20s, new file 41m 5s = less than 4 minutes difference. That is around a 10% increase and that is only true if each file will have the exact same time increase. Either way it is hard to help you further without you clarifying the question. – DanielBarbarian Jun 19 '14 at 11:50
  • LOC != Complexity, if the new code is more heavilly optimizable, it will add time, if the evaluations are more complex, it'll add time, inline calls will add time, everything adds time. Compiling is an extremely complex process and we can't simply say "It's a smaller file, so should compile faster" – Happington Jun 19 '14 at 12:50
  • Cont. Your #if 0 blocks may have actually been preventing some aspect of the optimization by breaking up bits of code. How does the RUN time of the programs differ? The actual binary size? – Happington Jun 19 '14 at 12:52
  • In order to answer you, I wrote a second edit. Thanks for your participation. – CloudCompany Jun 20 '14 at 07:10

0 Answers0