Compiler Arguments and Switches

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Jun 19 11:44:13 PDT 2006


"MM" <MM_member at pathlink.com> wrote in message 
news:e76p3q$1s3n$1 at digitaldaemon.com...

> What does this mean ?
> -inline
> inline expand functions

It means that the compiler will look at your functions, and if it finds a 
really trivial one,  like:

int foo(int x)
{
    return x * 2;
}

Whenever you call foo(), it'll replace it with the actual code from the 
function.  So

writefln(foo(4));

will be rewritten internally as

writefln(4 * 2);

Which then gets simplified down to

writefln(8);

This can improve execution speed a lot, as the overhead of calling the 
little function disappears.  The biggest speed difference would be if you 
called the function a lot of times; inlining it really speeds things up.

> I also don't really get the profiling part, but let me first read that a 
> bit
> more thoroughly :)

It's really handy.  You can turn on profiling, and when you run your 
program, it'll generate a profile log, which shows how many times every 
function was called, how long each function takes to execute (on average), 
and a bunch of other stuff.  Using that information, you can see which 
functions you probably need to work on speeding up (and which ones you don't 
that you thought were a bottleneck but really aren't!). 





More information about the Digitalmars-d-learn mailing list