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

Catalin Zamfir Alexandru catalin.zamfir at theg33ks.com
Wed Jun 13 09:22:27 CEST 2007


Guess because you're using inc(count) which may tell the compiler to use a 
specific procedure, specific procedure that may have its own hidden 
variables.

Use count := count + 1; and see what happens. This way you're not using the 
inc() procedure that may be specific to the system unit.

On Wednesday 13 June 2007 11:56, fpc at xgelb.de wrote:
> Hi
>
> I wrote two programs one in C and one in Freepascal.
>
> The program read a variable of a library  and write it to stdout. I will
> put it into a file: ("#: ./dataprog > file.dat"). I use "printf" in the C
> and "writeln" in  Freepascal.
>
> The problem: The fpc-based program is explicit slower than the c-based
> program. My questions:  Why is it so? Is it possible to avoid the problem?
>
>
> --------------
> C source:
>
> for (i=0;i<n;i++) {
>   out1=(single) libout1[i];
>   out2=(single) libout2[i];
>   count+=1;
>   printf("%20.0f%15.5f%15.5f\n",count,out1,out2);}
>
> --------------
> fpc source:
>
> for i:=0 to n do
> begin
>   out1:=single(libout1[i]);
>   out2:=single(libout2[i]);
>   inc(count);
>   writeln(stdout, count:20, out1:15:5, out2:15:5);
> end;
>
> --------------
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20070613/af5e1c74/attachment.sig>


More information about the fpc-pascal mailing list