Il 14/02/2016 11:09, Florian Klaempfl ha scritto:
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.
For the record:
Platform: Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz
OS: Linux CentOs 6
1) With FPC
Compiler: fpc 2.6.4.
Compiler flags: -O3 -Cr-
Inc(TicketsCount) replaced with TicketCounts:=TicketCounts+1
Original inner loop:
[colla@probookcolla SandBox]$ ./HappyTickets
Found 4816030 tickets. Elapsed time, msec: 215
(range from 215 to 225)
Florian's inner loop:
[colla@probookcolla SandBox]$ ./HappyTickets_florian
Found 4816030 tickets. Elapsed time, msec: 20
(range: from 17 to 26 ms)
2) With GNU C
Compiler: gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
Compiler flags: -O3
Found 4816030 tickets. Time elapsed: 80.0000 msec
[colla@probookcolla SandBox]$ ./happytickets
(range from 70 to 80 ms)
My conclusion:
depending on how you code, GCC wins over FPC by 3-1 or FPC wins over GCC
4-1!
Giuliano
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal