[fpc-pascal] options for better performance & declaration of system procedures

Joost van der Sluis joost at cnoc.nl
Thu Sep 24 10:57:42 CEST 2009

On Thu, 2009-09-24 at 16:31 +0800, 章宏九 wrote:
> Hi.
> I just tried to unfairly compare fpc-compiled binary and gcc-compiled
> binary under my Gentoo box. FPC is incredible. `ps` data shows the fpc
> one costs nearly no memory? But I still notice it is a little slow. It
> usually costs 0.5~1.0 time more than the gcc one. It seems as if fpc
> saves memory in the cost of performance loss. Is it true? If so, is
> there any options for better performance and no such insane memory
> saving?

Depends completely on what you are doing. In general fpc is known to use
not that much memory. If you want a faster executable you can try the
different optimization options. Also keep in mind that by default fpc
compiles code which can work on the oldest pentium processors. (or maybe
even i486?) Try for example -Oppentium4. (if you're not using 64-bit)

If you use writeln a lot, that's known to be slow by default because the
output buffer is rather small. You can use google for tips how to
increase this buffer.

> Interestingly, I just tried gpc also, gpc binary sometimes has a
> better performance, but even cost more memory than gcc, which is not
> tolerable.
> Another question. I cannot find any declaration of the system
> procedures such as WriteLn and ReadLn. I tried to find in fpcsrc
> directory with grep but achieve nothing. FreePascal's documents says
> the declarations are in rtl but the line number is 0. Are these system
> procedures implemented in the compiler(built-in) or in the system
> unit?

WriteLn and friends are implemented with some 'compiler-magic'. That's
because you can do things with writeln you can't do with other
procedures, like: writeln(stringtype, ': ', integertype); ie: use an
unlimited list of parameters which type may be almost everything.

>  I would like also to know the situation in C. (I mean
> declaration of printf and scanf. Are they implemented in glibc or
> gcc?)

gcc, I would guess. 


More information about the fpc-pascal mailing list