On 10/11/2014 08:52 AM, Benoît Minisini wrote:
> You're right, I thought that the number of occurrences was printed, not
> the result. Always look at the code before answering!:-)
>
> Well, as Fabien says, shows the Pascal code. I find strange that a
> compiled Pascal program is twice slower than an interpreted Gambas
> program. Or there is something weird in the Lazarus compiler?
>
> Regards,
>
> -- Benoît Minisini
I thought it was strange too, Benoît. But, at the same time, also
thought it was highly impressive on Gambas' (and its developers')
account. :-)
I have tried compiling the Pascal program with {$OPTIMIZATION ON} and
also {$RANGECHECKS OFF} (even though that should be the default) with no
improvement in performance.
Here's the Pascal code:
program Polynom;
{$mode objfpc}
var
z : integer;
function DoIt(x : double) : double;
var Mu : double = 10.0;
var Pu, Su : double;
var I, J, N : integer;
var aPoly : array [0..99] of double;
begin
N := 500000;
Pu := 0;
For I := 0 To N-1 do
begin
For J := 0 To 99 do
begin
Mu := (Mu + 2.0) / 2.0;
aPoly[J] := Mu;
end;
Su := 0.0;
For J := 0 To 99 do
begin
Su := X * Su + aPoly[J];
end;
Pu := Pu + Su;
end;
DoIt := Pu;
end;
Begin
For z := 1 To 10 do
begin
writeln( DoIt(0.2) );
end;
End.
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://p.sf.net/sfu/Zoho
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user