News for hackers. Stuff that matters.
Re:Why is strlen so complex in C? by bjourne on Tuesday August 27, 2019 @04:04AM (#20807266)
Did you benchmark it? I did and found that on a Core-M with MSVC, the optimized strlen beats the naive one by about 20% and on Xeon with gcc, by about 40%. Depending on string length and other parameters. I would expect the difference to be smaller on more recent processors. But without benchmarking I don't think you can say.
Re:Why is strlen so complex in C? by BeeOnRope on Tuesday August 27, 2019 @11:44AM (#20810849)
Yes, I have benchmarked it in the past which is where I got the 4-6x figure from. Maybe it's worth a revisit, but unless the compiler is doing something special with the byte version, I would be surprised if the speedup was much less.

You may have to unroll both to get max speed.

If you could share your benchmark I would be interested to look at it.

Re:Why is strlen so complex in C? by bjourne on Tuesday August 27, 2019 @05:09PM (#20814432)
Benchmarks are always worth revisits. Mine is here https://github.com/bjourne/c-examples/blob/master/programs/s...