Is there any code for a Pos() version that's as fast in 64-bit than the current 32-bit?
To my understanding, the 32-bit version in Delphi (tested up to XE5) adopted the FastCode assembler versions many years ago, but for 64-bit it uses a PurePascal version, which is around 5 to 10 times slower.
Some tests, same procedure in a long loop:
32-bit: 65..90ms
64-bit: 280..300ms
The C runtime function
wcsstr
as implemented in the system provided msvcrt.dll is better than Delphi RTLPos
for 64 bit code.32 bit release build
64 bit release build
Interestingly, the 32 bit
Pos
is clearly very well implemented.My system is running Win7 x64 on i5-2300.
Using
Fastcoders
purepascalPosEx_Sha_Pas_2
algorithm (modified to fit x64):And the result using David's test case (x64 release):
For the x32 release the results are:
Conclusion:
PosEx_Sha_Pas_2
is almost as fast in x64 bit mode asPos
in x32 bit mode. Additionally it seems asPosEx_Sha_Pas_2
is faster thanPos
in x32 bit mode.All tests here is with the XE4 version.
Improve purepascal System.Pos() still open in Tokyo 10.2.