Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spliting single file into multiple files in C - performance aspect

Tags:

performance

c

I have found a similar post on this topic but it address design aspect rather than performance so I am posting this to understand how breaking of a big c file affects compile and execution time.

I have a big utils files (all of us know quickly they grow). I am trying to understand if splitting the file into module based function files ( cookies.c, memcacheutils.c, stringutils.c, search.c, sort.c, arrayutils.c etc.) would add any penalty on compile and execution time.

My common sense says it would add some penalty as the code now has to find pointers in far fetch places rather than in the same file.

I could be horribly wrong or partially correct. Seeking guidance of all gurus. My current utils file is around 150k with 80+ functions.

Thank you for reading the post.

like image 427
Me Unagi Avatar asked Dec 12 '22 13:12

Me Unagi


1 Answers

Generally splitting your project into multiple compilation units allows for better project management and faster partial compilation. When you edit one file you only need to recompile that compilation unit and relink in order to test & debug.

Depending on your compiler though having all in one file may allow for additional inlining and functional optimisation. All at the cost of compilation time.

like image 190
Sergey L. Avatar answered Mar 29 '23 23:03

Sergey L.