[fpc-pascal] Re: put data to stdout (fpc vs. gcc)

L L at z505.com
Mon Jun 18 07:17:03 CEST 2007

> I know, programs with a writeln() have lower performance, but
> I think, printf() and writeln() must do the same. This need time to
> calculate.

You have to explain problem more.

The key thing to do is find your bottleneck. Write some benchmarks for float to string conversions
and put them in a loop. It could be concatenation or other things.

If you are interested you can also consider writing your own WriteLn to avoid some indirection and
abstraction. There is an example of writing your own text writeln driver here:


(kind of like an overloaded WriteLn, it is for web programming, you would need to write it for speed
whereas above is written for CGI).

See also:

That native_out unit writes to standard out without going through WriteLn system functions -
Anothony wrote his own stdout functions from scratch calling the winapi and the linux api's.

But don't try that until you first know what the bottleneck is, obviously. For web programming it
was just some fun premature optimization, but may be helpful for you if you have to write your own
writeln's and stdout functions.


More information about the fpc-pascal mailing list