4x faster strlen with 4 char sentinel
Jay Norwood via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Jun 28 08:18:37 PDT 2016
On Tuesday, 28 June 2016 at 09:18:34 UTC, qznc wrote:
> Did you also compare to strlen from libc? I'd guess GNU libc
> uses a lot more tricks like vector instructions.
I did test with the libc strlen, although the D libraries did not
have a strlen for dchar or wchar. I'm currently using this for
comparison, and playing around with shorter string lengths:
nothrow pure size_t strlen(const(char)* c) {
if (c is null )
return 0;
const(char)* c_save = c;
while (*c) {
c++;
}
return c - c_save;
}
I'm also trying some tests on a PA device where I have tools to
look at cache hits, misses, branches mispredicted. Similar C
code.
More information about the Digitalmars-d-announce
mailing list