force-net / Crc32.NET

Fast version of Crc32 algorithm for .NET
MIT License
199 stars 52 forks source link

Speed up. #8

Closed JosePineiro closed 6 years ago

JosePineiro commented 6 years ago

For each 16 bytes:

In precalc table Change one mult for one rotare right. (Only 16536 operations per execution.)

In my test speed up 8%

force-net commented 6 years ago

Hello Jose I've tested your code, it is slower ~5% About your changes:

Precalc table can be faster, but it is hard to catch difference because it is calculates only 1 time per application run.

JosePineiro commented 6 years ago

Sorry,

I do not think in parallel excecution. I my machine (AMD four cores) this change give a fast code. I suspected that the compiler precalculate constants. I do not see speed up with the change.

But I think that the change in precalc table are faster. You can test it precalculating the table a thousand times in each execution.

force-net commented 6 years ago

Can you provide a difference between your code and current code? Currently I did not have any good AMD computer for tests.

Precalc table may be slightly faster (but it hard question, jit can optimize both variants to the same code) but there are only one calculation per app lifecycle, so, it some CPU cycles that do not do any observable performance.