[fpc-pascal] Happy tickets benchmark

Jürgen Hestermann juergen.hestermann at gmx.de
Sun Feb 14 12:17:07 CET 2016


Am 2016-02-13 um 21:59 schrieb Paulo Costa:
 > 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

How can this happen?
As far as I remember, INC was introduced
to speed up this kind of calculation,
not to slow it down.
The compiler should be able to optimize
INC much easier than +1 within a (potentially)
complicated expression.




More information about the fpc-pascal mailing list