Re: what is fast dynamically linked executable or statically linked executable ?how to decide?
- From: "Stephen Sprunk" <stephen@xxxxxxxxxx>
- Date: Mon, 5 Mar 2007 08:56:08 -0600
"pratap" <pratappai78@xxxxxxxxx> wrote in message
news:1173075717.793186.290080@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Could someone clarify how could one reduce the size of an
executable code during compile time.
Could one use specific compile time flag with makefile or is it
advisable to go for dynamic linking.
The idea here is that smaller the code size the faster is the code.
Is Dynamically linked executable really faster than a single
executable file which is not linked dynamically.?
Your whole premise here is flawed; smaller does not mean faster. In fact,
most compilers have options to either compile for speed (e.g. gcc's -O3) or
for size (e.g. gcc's -Os), and the two are mutually exclusive. There are
lots of tricks modern compilers use to speed up code that actually make the
executable (sometimes significantly) bigger. Likewise, the tricks they use
to make code small often make executables significantly slower.
Dynamic linking may make your code faster or slower; it will almost always
make it smaller. The potential speed boost comes not from the size, though;
it comes from multiple copies of the same code being shared in memory
instead of duplicated, which reduces swapping and cache misses.
However, it all boils down to this: if you have to care about optimizations
at this level, you're most likely doing something seriously wrong.
S
--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com
.
- References:
- Prev by Date: Re: double vs float
- Next by Date: Re: Initialising variables with the comma
- Previous by thread: Re: what is fast dynamically linked executable or statically linked executable ?how to decide?
- Next by thread: Learn How To Speed Up Computer From Downloadable Video
- Index(es):
Relevant Pages
|