Code below, when compiled with -fno-builtin option works 5 times faster:
    #include <stdio.h>
    #include <string.h>

    int main(int argc, char *argv[])
    {
        char s[20] = "";
        int i, len;

        memset(s, 'a', sizeof(s)-1);
        for(i = 0; i < 10000000; ++i)
            len = strlen(s);
        printf("len: %d\n", len);
        return 0;
    }

My machine is Pentium IV


-- 
           Summary: [x86, 4.1] builtin strlen poor performance
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rdabrowa at poczta dot onet dot pl
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27077

Reply via email to