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

Benoît Minisini gambas at ...1...
Sat Oct 11 14:52:25 CEST 2014


Le 11/10/2014 06:58, T Lee Davidson a écrit :
> On 10/10/2014 08:50 PM, Benoît Minisini wrote:
>
> Thank you for trying to explain that to me. But, now I am really confused.
>
> As far as I can tell, the Gambas program also uses floating point
> numbers. The only integers I see used in that program are for an
> iterator, an array index, and an iterator boundary. Everything else is
> declared as a Float.
>
> ~~~
> Sub Test(X As Float) As Float
>
>     Dim Mu As Float = 10.0
>     Dim Pu, Su As Float
>     Dim I, J, N As Integer
>     Dim aPoly As New Float[100]
>
>     N = 500000
>
>     For I = 0 To N - 1
>       For J = 0 To 99
>         Mu =  (Mu + 2.0) / 2.0
>         aPoly[J] = Mu
>       Next
>       Su = 0.0
>       For J = 0 To 99
>         Su = X * Su + aPoly[J]
>       Next
>       Pu += Su
>     Next
>
>     Return Pu
>
> End
>
> Dim I as Integer
>
> For I = 1 To 10
>     Print Test(0.2)
> Next
> ~~~
>
> What am I missing?
>

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




More information about the User mailing list