4 ms·
Most c libraries have architecture-specific, hand-written assembly copies of strlen and have had them for decades. This includes glibc, almost from the day this
by compiler-guy 7y ago
Most c libraries have architecture-specific, hand-written assembly copies of strlen and have had them for decades. This includes glibc, almost from the day this particular function was checked in.
In other words, there actually is an SSE/SSE2/AVX implementation in glibc.
This copy in plain C is the fall-back to if the porter didn't implement strlen in assembly for the architecture they were porting to.
It is a reasonable guess at a somewhat architecturally-independent fast implementation. If someone really cares about squeezing all the performance they could out of strlen, they implement the assembly version.
Beyond that, many architectures that gcc supports don't include prefetchers, vector units and all the rest. The world is not all x86.