[fpc-pascal] options for better performance & declaration of system procedures
jonas.maebe at elis.ugent.be
Thu Sep 24 10:43:02 CEST 2009
On 24 Sep 2009, at 10:31, 章宏九 wrote:
> 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?
The FPC run time library is much less extensive than the GNU C library
(e.g., it does not include all of the locale information that the C
library has). In case you are linking statically, then you should also
note that the GNU C library is absolutely not optimized in any way to
produce small binaries when linking statically (while the FPC run
time library /is/ optimized for that purpose). A comparison with
something like uClibc would probably give somewhat more comparable
I'm also not sure how you are measuring "memory usage". If you are
looking at the VSIZE, note that this does not mean anything (since not
all that memory is actually used; RSS is better).
> 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?
No. FPC simply has a lot less optimization passes than gcc. Depending
on the compiled program and the host processor, this may matter a lot
or very little.
> If so, is
> there any options for better performance and no such insane memory
The memory usage is completely unrelated to the code speed.
> 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
read(ln)/write(ln) is handled internally in the compiler, and
translated into calls to different helpers in the RTL based on the
actually used types. You can find these helpers in rtl/inc/text.inc
(search for fpc_read and fpc_write). You can also compile with -al and
look at the resulting .s files to see how the compiler translates the
Pascal statements into assembler code (and which helpers it calls).
> I would like also to know the situation in C. (I mean
> declaration of printf and scanf. Are they implemented in glibc or
More information about the fpc-pascal