[fpc-pascal] Happy tickets benchmark
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Tue Feb 16 19:53:20 CET 2016
Serguei TARASSOV wrote:
>>>> >>Well, as said before: if the speed of code like this is important
>>>> for you,
>>>> >>use C.
>>> >It's a wrong choice.
>>> >As we can see and reproduce, at least C# or other Pascal-like
>>> environments
>>> >(Oxygene) are significantly faster.
>>> >http://www.arbinada.com/main/en/node/1532
>>> >
>> What Florian means is that this is very artificial code, and that -
>> although
>> he has been able to apply the necessary patches to make FPC faster - the
>> necessary optimizations are not likely to help in real-life programs.
>>
>> Michael.
>
> Sounds like the real-life programs don't use inner loops or don't solve
> NP-complete problems :)
> For info, my real-life examples are the application server and the DSL
> script engine.
> So any improvement of quality of FPC's generated code are welcome.
Anybody using a high-level language for real work would be advised to
understand the problem a bit better so that they didn't have to use your
sort of brute-force approach. And at that point, having something that
expresses higher-level algorithms and coding practices (threads, dynamic
arrays) becomes at least as important as brute force efficiency.
In the past I've come across people trying to solve recreational
problems asking (stupid) questions like "would Python be faster than
FORTRAN", and then having somebody respond that their approach is so
naive that language choice makes no real difference.
So in the case of your chosen problem: you know whether the left-hand
sum is even or odd, so a trivial optimisation would be only looking at
half of the possible values of the final (right-hand) digit. At which
point, pointing out that FPC doesn't have a STEP or BY clause in the FOR
statement would be far more useful criticism.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list