faster splitter

qznc via Digitalmars-d digitalmars-d at puremagic.com
Tue May 24 12:47:52 PDT 2016


On Tuesday, 24 May 2016 at 10:44:12 UTC, qznc wrote:
> Unfortunately, it is slower. My current measurements [0]:
>
> $ ./benchmark 10000000 10 # large haystack, few iterations
> std find    took    753837231
> manual find took    129561980
> $ ./benchmark 10 10000000 # small haystack, many iterations
> std find    took    721676721
> manual find took    216418870
>
> The nested-for-loop implementation is roughly 4 times faster!
>
> Caveat: I'm not completely sure my benchmark is fair yet.
>
> [0] https://github.com/qznc/find-is-too-slow

Plot twist: manual find is not always faster.

My benchmark now generates random haystack and needle. Sometimes 
Phobos clearly wins. Example:

$ ./benchmark.ldc -n39 -l10000 -i10000
Found at 10000
std find    took    289529102
manual find took    368958679

This is compiled with LDC, needle is 39 chars, haystack 10000 
chars, and 10000 iterations. "Found at 10000" means the needle 
was not found.

Very often manual find wins though. Takeaway: Manual find is too 
naive. However, something slows down std find in general. More 
research needed.

PS: Any recommendations for a Linux dissassembler? Objdump is ok, 
but some arrows for jumps would be nice.


More information about the Digitalmars-d mailing list