Well, as said before: if the speed of code like this is important for you, use C.
Am 15. Februar 2016 7:24:29 vorm. schrieb Adrian Veith <[email protected]>: > Hm, > > doing the same trick in C, it goes down from: > > 40ms (original) to 3ms (omit the inner loop). > > This is still the same distance to fpc (v 3.0.0 with -O4 -Ooloopunroll) > > 185ms (original) to 12ms (omit the inner loop). > > C is 4 times faster here. > > Am 14.02.2016 um 12:09 schrieb Michael Van Canneyt: >> >> >> On Sun, 14 Feb 2016, Florian Klaempfl wrote: >> >>> Am 14.02.2016 um 10:45 schrieb Mattias Gaertner: >>>> On Sun, 14 Feb 2016 10:35:22 +0100 >>>> Florian Klaempfl <[email protected]> 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. >> >> To back up Florian with numbers: >> >> No in: >> Found 4816030 tickets. Elapsed time, msec: 171 >> >> Using in: >> Found 4816030 tickets. Elapsed time, msec: 23 >> >> Michael. >> _______________________________________________ >> fpc-pascal maillist - [email protected] >> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > > _______________________________________________ > fpc-pascal maillist - [email protected] > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - [email protected] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
