[Gambas-user] Wow, Gambas is twice as fast as (Free) Pascal

Jussi Lahtinen jussi.lahtinen at ...626...
Sat Oct 11 20:37:50 CEST 2014


Something wrong here! Gambas and Pascal are different category programming
languages, interpreted and compiled. And thus this is hard to believe. So I
had to test this myself.

$ time ./polym_g.gambas
1250000
1250000
1250000
1250000
1250000
1250000
1250000
1250000
1250000
1250000

real    1m20.918s
user    1m20.814s
sys    0m0.077s


$ time ./polym
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006
 1.25000000000000E+006

real    0m5.395s
user    0m5.394s
sys    0m0.000s


As you can see, my numbers are something completely different. My test was
done with Intel Core2 Quad @ 2.83 GHz. And the Pascal version was compiled
with "fpc polym.pas".
What kind of system ran the Gambas code in 18 seconds!? And yet, how did it
spend 7 times more time on the Pascal program than my system!?

I try again with latest revision of Gambas later.


Jussi


On Sat, Oct 11, 2014 at 7:58 PM, Benoît Minisini <
gambas at ...1...> wrote:

> Le 11/10/2014 18:32, T Lee Davidson a écrit :
> >
> > 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.
> >
>
> It seems to be a perfect equivalent. So Gambas is faster, cool...
>
> If you succeed in converting the other benchmarks, I will add them to
> the wiki.
>
> Regards,
>
> --
> Benoît Minisini
>
>
> ------------------------------------------------------------------------------
> 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
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list