Re: Length of Variable Names Affect Compiled Executable?



John said:

Does the length of my C variable names have any affect, performance-wise,
on
my final executable program? I mean, once compiled, etc., is there any
difference between these two:
number = 3;
n = 3;

I know its setting aside storage for the variable itself; does it also use
up more storage if the variable name is longer? I realize it would
probably take quite a lot of long variable names to make any impact if so,
but I was just curious if anyone knew...

I have read the parallel replies with great interest and amusement. It's
amazing how much juice you can squeeze from C.

Nevertheless, *in general* the answer to your question is "no". Yes, various
people have drawn attention to various exceptions to that answer, which you
may wish to take into account. But in the general case, your implementation
will (or can be told to) discard all such information.

Thus, using b instead of CurrentBalance is an unnecessary "optimisation"
which will, in the general case, have no impact on performance. Write
clear, readable code using good algorithms and descriptive identifiers.
Worry about performance only in the extremely rare cases where good
algorithms don't deliver sufficient performance to meet your users' needs.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: Length of Variable Names Affect Compiled Executable?
    ... John wrote: ... my final executable program? ... I know its setting aside storage for the variable itself; does it also use up more storage if the variable name is longer? ... A typical case of something similar is the assert macro (which people sometimes leave active in the release code by #undef'ing NDEBUG by hand). ...
    (comp.lang.c)
  • Re: Length of Variable Names Affect Compiled Executable?
    ... John wrote: ... my final executable program? ... I know its setting aside storage for the variable itself; does it also use up more storage if the variable name is longer? ... Joe Wright ...
    (comp.lang.c)
  • Re: IBM using more below the line storage.
    ... No offense to you or John, but given that John Eells and Peter Relson, both ... PLPA requirements for IBM products have dropped from OS/390 2.10 and z/OS ... IBM using more below the line storage. ...
    (bit.listserv.ibm-main)
  • Re: bit fields pointers?
    ... little monsters in a distributed berkelydb ... At this point we start getting into algorithms questions rather than ... We would also need some idea about probability distributions ... storage can be achieved by using probablistic storage rather than ...
    (comp.lang.c)
  • Re: Measuring the number of operations in Matlab
    ... > Carlos, John, Steven, ... > with a PC or another modern general-purpose platform. ... Scientific analysis of the cost of algorithms - which method to ... The old flops code did nothing more than provide a single ...
    (comp.soft-sys.matlab)