Hello,
I'd like to provide a small
VS.NET project file with 5 different tests.
- 46ffffe9 tells everything is alright with the function calculation
- times are measured with QueryPerformanceCounter
- loop run cnt: 0x2ffffff
result orig function 46ffffe9
it took 1491052
result orig function inlined 46ffffe9
it took 1035547
result second proposal inlined 46ffffe9
it took 1244434
result optimized asm 46ffffe9
it took 1338367
result debug asm 46ffffe9
it took 8774815
The second proposal is the original proposal but more shifts - still slower
tho.
Interesting is the inlined version generated by MSVC, shaving off almost 1/3
of the overall time.
Also stared as "optimized asm" - no gurantee on register safety tho ;)
For portability and performance sake it should be considered to create a
compiler macro.
This function is terribly small, any optimisations inside are outweighted by
the calling overhead in this case.
The most impressive one is the original function inlined, althought the ASM
would only work on x86.
Please do not think about using 64k tables, thats what, 1/2 of a Sempron L2
cache?
It would really really trash performance.
Available at: <a
href="http://hackersquest.org/kerneltest.html"
title="Kernel Test Emulator">Kernel Test</a>
<a
href="http://wohngebaeudeversicherung.einsurance.de/">http://wohngebaeudeversicherung.einsurance.de</a>