[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:

http://opensvn.csie.org/pspcgi/psp-1.6.0.2-release/extras/webcrt/

(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:
http://opensvn.csie.org/pspcgi/psp-1.6.0.2-release/main/native_out.pas

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.

Lars




More information about the fpc-pascal mailing list