Interesting performance results on Crc port from zlib
Igor
stojkovic.igor at gmail.com
Mon Jan 25 19:10:51 UTC 2021
On Sunday, 24 January 2021 at 17:55:20 UTC, welkam wrote:
> On Sunday, 24 January 2021 at 16:23:24 UTC, Igor wrote:
>> ldc2 -c -O3 source/crc32.d test/test.d
>
> Edited the command for clarity. As I suspected the compiler can
> see the whole programs source code and because of that it can
> perform better optimizations. If you tried to compile C version
> with link time optimizations you might get similar results.
It seems you are right. I edited the example.c that comes with
zlib to just do CRC calculation 100_000 times on 4K buffer and
compiled it with its make file. But it first made a libz.a static
lib and then it compiled example.c and linked them together. This
resulted in executable that still calculates CRC in 262ms. But
then I included crc32.c directly into example.c and compiled it
as single compilation unit and now it does the job in 96ms. Same
happened when I linked it with static lib using gcc -flto so LTO
is used.
I had no idea this can have such big impact on performance.
That's it, I am just using source libraries from now on :D
More information about the Digitalmars-d
mailing list