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

T Lee Davidson t.lee.davidson at ...626...
Fri Oct 17 06:49:57 CEST 2014


I feel responsible to make a correction. After further research, I have 
discovered that Gambas, doing the Polynomial benchmark, is not faster 
than the pre-compiled Free Pascal program.

I thought it might be prudent, before adding any Pascal benchmarks to 
the Wiki, to see if there might be some way to optimize the compilation 
of the Pascal program -- which is usually the case for just about any 
compiled language. Plus, I thought there might be something wrong with 
my system's Free Pascal Compiler (FPC) configuration that made my 
relative results so disparate from Jussi's. So I took the little 
Polynomial benchmark, and my results thus far, to the Free Pascal forum.

With their assistance, I had gotten the performance ratio between the 
Pascal program and the Gambas program down to 1.37:1 on my system, which 
was real close to Jussi's performance ratio of 1.29:1 (5.376s / 4.172s). 
I was satisfied with that.

They, on the other hand, apparently were not ;-)

Long story short, FPC can make use of a unit (similar to a Gambas 
module) for floating point code. FPC for the x86-64 automatically uses 
this unit for floating point code due to the fact that all x86-64 CPUs 
support it. I, on the other hand, had to specifically tell the compiler 
to use that unit so the FPU on my Pentium4 could be utilized. That 
combined with what they call Level 2 optimization, for this particular 
program, significantly increased the performance of the compiled Pascal 
program.

Anyone so inclined can read more about Level 1-3 optimizations at 
http://www.freepascal.org/docs-html/prog/progse49.html#x255-26800011.3


A 64-bit sytem user would need compile only with:
`fpc -O2 polynom.pas`

But I had to use (the SSE2 unit):
`fpc -Cfsse2 -O2 polynom.pas`

Here are my latest results with program output omitted.

The Pascal program:
$ time ./polynom
[...]
real    0m9.910s
user    0m8.685s
sys     0m0.031s

The Gambas program, first run:
$ time gbs3 -f polynom.gambas
[...]
real    0m12.573s
user    0m9.607s
sys     0m0.083s

The Gambas program, second run (making use of the compile cache?):
$ time gbs3 -f polynom.gambas
[...]
real    0m11.143s
user    0m9.717s
sys     0m0.046s


So Gambas is still right up there in performance :-) Well, taking out 
compile time, and for this particular program.


Is there still a place for Pascal program benchmarks on the Wiki? ;-) If 
so, I'll try to work on that when I can manage to find some "play" time.


Lee



On 10/11/2014 08:24 PM, Jussi Lahtinen wrote:
> My cleaning script didn't include "rm -f /usr/local/bin/gbs3" and
> apparently because of changed paths "make install" didn't overwrite old
> version. So my gbs3 had version number 3.2.90, and no -f option (it was
> simply ignored)!
> Just to warn others, you may want to check whether you too have two
> versions of gbs3 installed (in /usr/local/bin/gbs3 and in /usr/bin/gbs3).
> If you do, remove the files, run "sudo make install" again and restart your
> terminal.
>
> $ time gbs3 -c -f polym.gambas
> 1250000
> 1250000
> 1250000
> 1250000
> 1250000
> 1250000
> 1250000
> 1250000
> 1250000
> 1250000
>
> real    0m4.172s
> user    0m4.158s
> sys    0m0.012s
>
>
> $ 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.376s
> user    0m5.374s
> sys    0m0.000s
>
>
> So, Gambas really is faster in fair comparison!
>
>
>
>
> Jussi
>
>




More information about the User mailing list