httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail T." <mi+t...@aldan.algebra.com>
Subject Re: strncasecmp
Date Tue, 24 Nov 2015 05:10:53 GMT
On 23.11.2015 23:14, William A Rowe Jr wrote:
> L1 cache and other direct effects of cpu internal optimization.
Just what I was thinking. Attached is the same program with one more
pair of functions added (and an easy way to add more "candidates" to the
main-driver). I changed the FOR-loop define to obtain repeatable results:

    # Test 1 -- equal strings:
    foreach m ( 0 1 2 )
    foreach? ./strncasecmp $m 100000000 aaaaaaaaa AAAAAAAAA 7
    foreach? end
    string.h (nb=100000000, len=7)
    time = 6.975845 : res = 0
    optimized (nb=100000000, len=7)
    time = 1.492197 : res = 0
    'A' - 'a' (nb=100000000, len=7)
    time = 1.787807 : res = 0

    # Test 2 -- immediately-different strings
    foreach m ( 0 1 2 )
    foreach? ./strncasecmp $m 100000000 aaaaaaaaa xAAAAAAAA 7
    foreach? end
    string.h (nb=100000000, len=7)
    time = 2.527727 : res = -23
    optimized (nb=100000000, len=7)
    time = 0.406867 : res = -23
    'A' - 'a' (nb=100000000, len=7)
    time = 0.440320 : res = -23

    # Test 3 -- strings different at the very end
    foreach m ( 0 1 2 )
    foreach? ./strncasecmp $m 100000000 aaaaaaaaa AAAAAAAAx 0
    foreach? end
    string.h (nb=100000000, len=0)
    time = 9.629660 : res = -23
    optimized (nb=100000000, len=0)
    time = 1.387208 : res = -23
    'A' - 'a' (nb=100000000, len=0)
    time = 1.754683 : res = -23

The new pair (method 2) does not use the static table, which is likely
to benefit from CPU-cache unfairly in repetitive benchmarks.  It is
slower than the table-using method 1 functions. But the two pairs might
be comparable -- or even faster -- in real life.

    -mi


Mime
View raw message