Happy tickets benchmark

classic Classic list List threaded Threaded
75 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Happy tickets benchmark

Serguei TARASSOV
Hello,

Here is my little brute-force test for FPC, C and C# compilers.
http://arbinada.com/main/en/node/1532

The results are not so good with FPC but I cannot use Delphi to compare
on Linux.

Could anyone make the series on Windows with FPC, Delphi and MS .Net?
The test of FPC 3.0 and any other comments are welcome.

Regards,
Serguei
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
--
Regards,
Serguei
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

silvioprog
On Sat, Feb 13, 2016 at 7:44 AM, Serguei TARASSOV <[hidden email]> wrote:
Hello,

Here is my little brute-force test for FPC, C and C# compilers.
http://arbinada.com/main/en/node/1532

Thanks for share the test. The result for Core i7 2.20 GHz 6 GB Windows 7 64 bits FPC 3.0 (last week trunk):

Found 4816030 tickets. Elapsed time, msec: 268
 
The results are not so good with FPC but I cannot use Delphi to compare on Linux.

Could anyone make the series on Windows with FPC, Delphi and MS .Net?
The test of FPC 3.0 and any other comments are welcome.

Delphi on Linux, how? o_O

--
Silvio Clécio

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

vojtech.cihak
In reply to this post by Serguei TARASSOV

Hi,

 

64-bit Linux, Core2Duo@2GHz, FPC3.0.0:

 

Pascal: 440 ms

C:  163ms

Delphi )*: 515ms

 

)* Delphi7, personal edition, under wine, command: wine happyd7.exe

______________________________________________________________
> Od: Serguei TARASSOV <[hidden email]>
> Komu: <[hidden email]>
> Datum: 13.02.2016 11:44
> Předmět: [fpc-pascal] Happy tickets benchmark
>

Hello,

Here is my little brute-force test for FPC, C and C# compilers.
http://arbinada.com/main/en/node/1532

The results are not so good with FPC but I cannot use Delphi to compare
on Linux.

Could anyone make the series on Windows with FPC, Delphi and MS .Net?
The test of FPC 3.0 and any other comments are welcome.

Regards,
Serguei
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

silvioprog
On Sat, Feb 13, 2016 at 8:36 AM, Vojtěch Čihák <[hidden email]> wrote:

Hi,

 

64-bit Linux, Core2Duo@2GHz, FPC3.0.0:

 

Pascal: 440 ms

C:  163ms

Delphi )*: 515ms

 

)* Delphi7, personal edition, under wine, command: wine happyd7.exe


I think that the C code has a small problem:

Found tickets. Time elapsed: 0 msec

Just added the %d instead of %:

printf("Found %d tickets. Time elapsed: %.0f msec\n", tickets_count, msec);

Now:

gcc happytickets.c -O2 -o happytickets
./happytickets
Found 4816030 tickets. Time elapsed: 0 msec

Core i7 2.20 GHz 6 GB Windows 7 64 bits
gcc version 5.2.0 (Rev4, Built by MSYS2 project) MinGW-w64

--
Silvio Clécio

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Martin Schreiber-2
In reply to this post by Serguei TARASSOV
On Saturday 13 February 2016 11:44:27 Serguei TARASSOV wrote:
> Hello,
>
> Here is my little brute-force test for FPC, C and C# compilers.
> http://arbinada.com/main/en/node/1532
>

A slightely modified testcase because MSElang has no RTL yet:
"
program test;
 
var
  n1, n2, n3, n4, n5, n6, n7, n8: 0..9;
  TicketsCount: int32;
  i1: int32;
begin
 for i1:= 0 to 9 do begin
  TicketsCount := 0;
  for n1 := 0 to 9 do
    for n2 := 0 to 9 do
      for n3 := 0 to 9 do
        for n4 := 0 to 9 do
          for n5 := 0 to 9 do
            for n6 := 0 to 9 do
              for n7 := 0 to 9 do
                for n8 := 0 to 9 do
                  if n1 + n2 + n3 + n4 = n5 + n6 + n7 + n8 then
                    inc(TicketsCount);
 end;
 writeln('Found ', TicketsCount, ' tickets.');
end.
"
"
#include <stdio.h>
#include <stdint.h>
 
int main()
{
  unsigned char n1, n2, n3, n4, n5, n6, n7, n8;
  int i1;
  int tickets_count;
 for (i1 = 0; i1 < 10; i1++){
  tickets_count = 0;
  for (n1 = 0; n1 < 10; n1++)
    for (n2 = 0; n2 < 10; n2++)
      for (n3 = 0; n3 < 10; n3++)
        for (n4 = 0; n4 < 10; n4++)
          for (n5 = 0; n5 < 10; n5++)
            for (n6 = 0; n6 < 10; n6++)
              for (n7 = 0; n7 < 10; n7++)
                for (n8 = 0; n8 < 10; n8++)
                  if (n1 + n2 + n3 + n4 == n5 + n6 + n7 + n8)
                    tickets_count++;
 }
  printf("Found %i tickets.",tickets_count);
  return 0;
}
"
MSElang with LLVM 3.7.0 backend -O3:
"
time ./test.bin
Found 4816030 tickets.

real    0m0.997s
user    0m0.993s
sys     0m0.003s
"
FPC 3.0 -O3:
"
time ./testfpc.bin
Found 4816030 tickets.

real    0m5.576s
user    0m5.572s
sys     0m0.002s
"
gcc 4.8.1 -O3:
"
time ./testgcc.bin
Found 4816030 tickets.
real    0m1.649s
user    0m1.645s
sys     0m0.002s
"
Stripped binary size:
MSElang    5.5KB
FPC 3.0   21.6KB
gcc 4.8.1  5.5KB

Linux x86, AMD Athlon 4000+ 1GHz

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Michael Van Canneyt


On Sat, 13 Feb 2016, Martin Schreiber wrote:

> time ./testgcc.bin
> Found 4816030 tickets.
> real    0m1.649s
> user    0m1.645s
> sys     0m0.002s
> "
> Stripped binary size:
> MSElang    5.5KB
> FPC 3.0   21.6KB
> gcc 4.8.1  5.5KB
>
> Linux x86, AMD Athlon 4000+ 1GHz

No surprises there, you are comparing FPC with llvm.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

leledumbo
Administrator
In reply to this post by Martin Schreiber-2
> Stripped binary size:
> MSElang    5.5KB
> FPC 3.0   21.6KB
> gcc 4.8.1  5.5KB

-static flag must be missing for C(-backend) :p
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

leledumbo
Administrator
In reply to this post by Serguei TARASSOV
Here's a test from my machine (Manjaro Linux x86_64 KDE desktop kernel 4.4.1 Core i5-4200u):

$ fpc -CX -XXs -O3 test.pas
Hint: End of reading config file /etc/fpc.cfg
Target OS: Linux for x86-64
Compiling test.pas
Linking test















/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
25 lines compiled, 0.4 sec
1 hint(s) issued
$ time ./test
Found 4816030 tickets. Elapsed time, msec: 225

real 0m0.226s
user 0m0.223s
sys 0m0.000s
$ clang -o test -s -O3 test.c
$ time ./test
Found 4816030 tickets. Time elapsed: 70 msec

real 0m0.071s
user 0m0.070s
sys 0m0.000s
$ gcc -o test -s -O3 test.c
$ time ./test
Found 4816030 tickets. Time elapsed: 109 msec

real 0m0.110s
user 0m0.107s
sys 0m0.000s
$ mcs test.cs -optimize
$ time mono test.exe
Found 4816030 tickets. Time elapsed: 236 msec

real 0m0.267s
user 0m0.260s
sys 0m0.003s

Below is the produced assembly from fpc, gcc and clang (no idea how to get one for mono):
test.s
test.s
test.s

I hope they can be optimizers' / code generator writers' reference to improve our compiler.

Anyway, I've tried changing the for loop into while since Pascal's for isn't a syntactic sugar for while as in C's for, but apparently that didn't change anything so the emitted code is already as best as it can.
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

leledumbo
Administrator
Damn, nabble doesn't like the double file extension :(
Reuploaded:
FPC: test.pas_s
GCC: test.gcc_s
Clang: test.clang_s
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

vojtech.cihak
In reply to this post by leledumbo

Thanks, but assembler links are wrong, all seem to point to test.c.

 

V. aka Blaazen

 

______________________________________________________________
> Od: leledumbo <[hidden email]>
> Komu: <[hidden email]>
> Datum: 13.02.2016 18:43
> Předmět: Re: [fpc-pascal] Happy tickets benchmark
>

Here's a test from my machine (Manjaro Linux x86_64 KDE desktop kernel 4.4.1
Core i5-4200u):


Below is the produced assembly from fpc, gcc and clang (no idea how to get
one for mono):
test.s
<http://free-pascal-general.1045716.n5.nabble.com/file/n5724116/test.s>  
test.s
<http://free-pascal-general.1045716.n5.nabble.com/file/n5724116/test.s>  
test.s
<http://free-pascal-general.1045716.n5.nabble.com/file/n5724116/test.s>  

I hope they can be optimizers' / code generator writers' reference to
improve our compiler.

Anyway, I've tried changing the for loop into while since Pascal's for isn't
a syntactic sugar for while as in C's for, but apparently that didn't change
anything so the emitted code is already as best as it can.



--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Happy-tickets-benchmark-tp5724109p5724116.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Paulo Costa-2
In reply to this post by Serguei TARASSOV
On 13-Feb-16 10:44, Serguei TARASSOV wrote:
> Could anyone make the series on Windows with FPC, Delphi and MS .Net?
> The test of FPC 3.0 and any other comments are welcome.

On my PC with Windows 8.1, fpc 2.6.4 32bits, when I changed the line:
inc(TicketsCount);
to:
TicketsCount := TicketsCount + 1;

the results improved from:
C:\tmp\tests>HappyTickets.exe
Found 4816030 tickets. Elapsed time, msec: 323

to

C:\tmp\tests>HappyTickets.exe
Found 4816030 tickets. Elapsed time, msec: 262


Paulo Costa
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

vojtech.cihak

I can confirm, Inc(); is slower. Change decreased time from 440 to 390 ms.

 

Quick test (empty project in Laz.):

unit1.pas:35                              inc(TicketsCount);

000000000046DB18 4883c001                 add    $0x1,%rax

unit1.pas:36                              TicketsCount+=1;

000000000046DB1C 488d4001                 lea    0x1(%rax),%rax

unit1.pas:37                              TicketsCount:=TicketsCount+1;

000000000046DB20 488d5801                 lea    0x1(%rax),%rbx

______________________________________________________________
> Od: Paulo Costa <[hidden email]>
> Komu: <[hidden email]>
> Datum: 13.02.2016 22:00
> Předmět: Re: [fpc-pascal] Happy tickets benchmark
>

On 13-Feb-16 10:44, Serguei TARASSOV wrote:
> Could anyone make the series on Windows with FPC, Delphi and MS .Net?
> The test of FPC 3.0 and any other comments are welcome.

On my PC with Windows 8.1, fpc 2.6.4 32bits, when I changed the line:
inc(TicketsCount);
to:
TicketsCount := TicketsCount + 1;

the results improved from:
C:\tmp\tests>HappyTickets.exe
Found 4816030 tickets. Elapsed time, msec: 323

to

C:\tmp\tests>HappyTickets.exe
Found 4816030 tickets. Elapsed time, msec: 262


Paulo Costa
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

wkitty42
On 02/13/2016 04:21 PM, Vojtěch Čihák wrote:
> I can confirm, Inc(); is slower. Change decreased time from 440 to 390 ms.

my 10 run averages seems to all be right in the same neighborhood... maybe my
machine has a lot more going on in the background which is affecting my
simplistic testing?

AMD Vishera Black FX 8350 8-core 4Ghz 16.0MB cache
Kubuntu 14.04 - 16GB RAM - there are at least 8 VMs running at all times plus
several servers and numerous user apps...


FWIW: these are the results of my tests...

===== inc(TicketsCount) =====
~/development/projects/misc$ for foo in 0 1 2 3 4 5 6 7 8 9; do time
./happytickets; done;
Found 4816030 tickets. Elapsed time, msec: 331

real    0m0.333s
user    0m0.316s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 341

real    0m0.344s
user    0m0.326s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 315

real    0m0.317s
user    0m0.303s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 323

real    0m0.325s
user    0m0.325s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 336

real    0m0.340s
user    0m0.315s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 320

real    0m0.321s
user    0m0.320s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 318

real    0m0.319s
user    0m0.315s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 388

real    0m0.390s
user    0m0.309s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 278

real    0m0.281s
user    0m0.265s
sys     0m0.004s
Found 4816030 tickets. Elapsed time, msec: 297

real    0m0.298s
user    0m0.298s
sys     0m0.000s
===== end =====

===== TicketsCount += 1 =====
~/development/projects/misc$ for foo in 0 1 2 3 4 5 6 7 8 9; do time
./happytickets; done;
Found 4816030 tickets. Elapsed time, msec: 319

real    0m0.321s
user    0m0.311s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 301

real    0m0.302s
user    0m0.302s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 297

real    0m0.299s
user    0m0.277s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 309

real    0m0.310s
user    0m0.310s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 274

real    0m0.275s
user    0m0.274s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 348

real    0m0.356s
user    0m0.325s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 333

real    0m0.334s
user    0m0.319s
sys     0m0.004s
Found 4816030 tickets. Elapsed time, msec: 256

real    0m0.257s
user    0m0.257s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 288

real    0m0.289s
user    0m0.289s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 249

real    0m0.251s
user    0m0.251s
sys     0m0.000s
===== end =====

===== TicketsCount := TicketsCount + 1 =====
~/development/projects/misc$ for foo in 0 1 2 3 4 5 6 7 8 9; do time
./happytickets; done;
Found 4816030 tickets. Elapsed time, msec: 381

real    0m0.383s
user    0m0.328s
sys     0m0.004s
Found 4816030 tickets. Elapsed time, msec: 301

real    0m0.302s
user    0m0.298s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 308

real    0m0.310s
user    0m0.310s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 322

real    0m0.375s
user    0m0.318s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 308

real    0m0.314s
user    0m0.309s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 325

real    0m0.327s
user    0m0.327s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 318

real    0m0.319s
user    0m0.319s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 286

real    0m0.290s
user    0m0.286s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 247

real    0m0.248s
user    0m0.248s
sys     0m0.000s
Found 4816030 tickets. Elapsed time, msec: 290

real    0m0.292s
user    0m0.290s
sys     0m0.000s
===== end =====


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list* unless
        private contact is specifically requested and granted.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Florian Klämpfl
In reply to this post by Serguei TARASSOV
Am 13.02.2016 um 11:44 schrieb Serguei TARASSOV:

> Hello,
>
> Here is my little brute-force test for FPC, C and C# compilers.
> http://arbinada.com/main/en/node/1532
>
> The results are not so good with FPC but I cannot use Delphi to compare
> on Linux.
>
> Could anyone make the series on Windows with FPC, Delphi and MS .Net?
> The test of FPC 3.0 and any other comments are welcome.

For the record: with a few changes in the compiler I could reduce the
execution time of the example significantly . But I won't commit it
probably (maybe parts of it): extensive loop unrolling and loop
invariant search has normally little advantages in real world programs
and increases only compilation times.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Mattias Gaertner
On Sun, 14 Feb 2016 10:11:54 +0100
Florian Klaempfl <[hidden email]> wrote:

>[...]
> For the record: with a few changes in the compiler I could reduce the
> execution time of the example significantly . But I won't commit it
> probably (maybe parts of it): extensive loop unrolling and loop
> invariant search has normally little advantages in real world programs
> and increases only compilation times.

If it is easy to implement could it be optional?

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Florian Klämpfl
Am 14.02.2016 um 10:23 schrieb Mattias Gaertner:

> On Sun, 14 Feb 2016 10:11:54 +0100
> Florian Klaempfl <[hidden email]> wrote:
>
>> [...]
>> For the record: with a few changes in the compiler I could reduce the
>> execution time of the example significantly . But I won't commit it
>> probably (maybe parts of it): extensive loop unrolling and loop
>> invariant search has normally little advantages in real world programs
>> and increases only compilation times.
>
> If it is easy to implement could it be optional?

Do you think people will bother? Nobody mentioned to the original poster
so far:
- that the used FPC is outdated
- that only -O2 is used instead of -O3 (or -O4 with 3.0.0)
- that even FPC 2.6.4 has a -Ooloopunroll option which is never enabled
by default and which is worth a try

I do not know if the points above really effect the example, but it
tells me enough not to bother either :)


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Mattias Gaertner
On Sun, 14 Feb 2016 10:35:22 +0100
Florian Klaempfl <[hidden email]> wrote:

>[...]
> Do you think people will bother? Nobody mentioned to the original poster
> so far:
> - that the used FPC is outdated
> - that only -O2 is used instead of -O3 (or -O4 with 3.0.0)
> - that even FPC 2.6.4 has a -Ooloopunroll option which is never enabled
> by default and which is worth a try
>
> I do not know if the points above really effect the example, but it
> tells me enough not to bother either :)

Maybe documentation helps here.

Is there already a page "pimp my fpc"?

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Adrian Veith-2
In reply to this post by Serguei TARASSOV
When I change the programm to run inside a procedure (because this would
be the more realistic scenario) the performance decreases about 15% -
160ms in global vs 185ms inside procedure.

program HappyTickets;

uses
  SysUtils, DateUtils;

procedure run;
  var
    n1, n2, n3, n4, n5, n6, n7, n8: 0..9;
    TicketsCount: int64;
    d1, d2: TDateTime;
  begin
    TicketsCount := 0;
    d1 := Now;
    for n1 := 0 to 9 do
      for n2 := 0 to 9 do
        for n3 := 0 to 9 do
          for n4 := 0 to 9 do
            for n5 := 0 to 9 do
              for n6 := 0 to 9 do
                for n7 := 0 to 9 do
                  for n8 := 0 to 9 do
                    if n1 + n2 + n3 + n4 = n5 + n6 + n7 + n8 then
                      TicketsCount := TicketsCount + 1; //
Inc(TicketsCount) may be slower in FPC
    d2 := Now;
    writeln('Found ', TicketsCount, ' tickets. Elapsed time, msec: ',
DateUtils.MilliSecondsBetween(d1, d2));
  end;

begin
    run;
end.


Am 13.02.2016 um 11:44 schrieb Serguei TARASSOV:

> Hello,
>
> Here is my little brute-force test for FPC, C and C# compilers.
> http://arbinada.com/main/en/node/1532
>
> The results are not so good with FPC but I cannot use Delphi to
> compare on Linux.
>
> Could anyone make the series on Windows with FPC, Delphi and MS .Net?
> The test of FPC 3.0 and any other comments are welcome.
>
> Regards,
> Serguei
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Serguei TARASSOV
In reply to this post by Serguei TARASSOV
Hello,

thank all for assistance!

Sorry, I was not clear, the series should be ran with all tests _on the
same computer_ regardless its hardware capacity and on the _same OS_.
That's why I cannot compare with Delphi.

So if you have modern Delphi, FPC and maybe .NET on your Windows
computer please compare them with about 5-10 runs to get average time.

Thank you for the Inc() hint, I added it to the comments, it gains about
10% for me.
However, in Delphi Inc() is faster until you turn on the checking overflow.

Another strange effect in FPC.
Only longint shows correct result. With the integer type the optimizer
seems to replace type with shortint (16-bits) and I see 31902 instead of
4816030.

Regards,
Serguei
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
--
Regards,
Serguei
Reply | Threaded
Open this post in threaded view
|

Re: Happy tickets benchmark

Florian Klämpfl
In reply to this post by Mattias Gaertner
Am 14.02.2016 um 10:45 schrieb Mattias Gaertner:

> On Sun, 14 Feb 2016 10:35:22 +0100
> Florian Klaempfl <[hidden email]> wrote:
>
>> [...]
>> Do you think people will bother? Nobody mentioned to the original poster
>> so far:
>> - that the used FPC is outdated
>> - that only -O2 is used instead of -O3 (or -O4 with 3.0.0)
>> - that even FPC 2.6.4 has a -Ooloopunroll option which is never enabled
>> by default and which is worth a try
>>
>> I do not know if the points above really effect the example, but it
>> tells me enough not to bother either :)
>
> Maybe documentation helps here.

You mean something like the page Size Matters? See the post of Martin
Schreiber how much such pages help.

>
> Is there already a page "pimp my fpc"?

In this case even fpc -h would have helped :)

But actually, before bothering randomly with command line options, I
would just rewrite the inner loop. Something like
              for n7 := 0 to 9 do
                if n1 + n2 + n3 + n4 - n5 - n6 - n7 in [0..9] then
                  Inc(TicketsCount);
should be much better.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
1234