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

Benoît Minisini gambas at ...1...
Fri Oct 17 07:42:27 CEST 2014


Le 17/10/2014 06:49, T Lee Davidson a écrit :
> 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.
>

Yes, of course. If you succeed in writing the benchmarks in Pascal (they 
are not so complex), and in compiling it "correctly", just send me the 
source files and tell me exactly how to compile them: I will run them on 
my machine (this is the reference), and I will update the wiki.

Regards,

-- 
Benoît Minisini




More information about the User mailing list