faster splitter
Chris via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 30 02:03:44 PDT 2016
It's weird, on my machine, my find function is consistently
faster than `manual find`
LDC:
std find: 137 ±22 +33 (3580) -17 (6251)
manual find: 137 ±32 +53 (3105) -23 (6834)
qznc find: 106 ±8 +17 (2608) -5 (7195)
Chris find: 132 ±32 +58 (2803) -23 (7131)
Andrei find: 120 ±26 +54 (2466) -17 (7454)
===
std find: 136 ±22 +33 (3503) -17 (6304)
manual find: 137 ±33 +55 (3000) -23 (6920)
qznc find: 106 ±8 +17 (2535) -5 (7287)
Chris find: 132 ±33 +59 (2803) -23 (7137)
Andrei find: 119 ±25 +51 (2569) -16 (7374)
It's negligible, but I wonder is it the extra initialization:
`size_t end = haystack.length - needle.length + 1;`
and
`size_t i = 0` is defined, before we know, if it's a legitimate
search. But that shouldn't matter, or should it?
Or does it depend on the machine?
DMD slows all searches down considerably (except for `qznc find`,
well done!:)
DMD:
std find: 161 ±36 +46 (4015) -31 (5847)
manual find: 147 ±40 +68 (3001) -28 (6917)
qznc find: 106 ±8 +15 (2623) -5 (7172)
Chris find: 201 ±41 +73 (2830) -28 (7120)
Andrei find: 150 ±40 +61 (3347) -30 (6575)
PS I've corrected the end of the search string to
`outer:
for (auto i = 0; i < haystack.length-(needle.length-1); i++)`
else it will not match at the end of a string.
More information about the Digitalmars-d
mailing list