Spliting single file into multiple files in C - performance aspect
c, performance
Solution
This used to matter when you had 16-bit PCs with different segments. Far (and worse, "huge") pointers carried a performance cost as you had to start fooling around with segment registers.
Nowadays with 32-bit addressing there should be no cost. Ultimately if you're that worried about performance then you begin to consider "jump tables" in assembly which require the target address to be in a short distance relative to the current instruction.
In C, then, you really should aim to put your code in different modules (read about software "cohesion" and "coupling" theoretical issues). There should be no difference in execution time. As far as compile time goes it "depends" - especially if you are including files repeatedly. In a big project having multiple files is a massive time saver as you can recompile only that unit of code that changed. In a small project compilation time is so small to be relatively insignificant to worry about efficiency.
Problem
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.