#include <stdio.h> #include "../common.h" main() { char *s0 = "The quick brown fox jumps over the lazy dog\n123"; char *s1 = "1The quick brown fox jumps over the lazy dog\n23"; char *s2 = "12The quick brown fox jumps over the lazy dog\n3"; char *s3 = "123The quick brown fox jumps over the lazy dog\n"; char *s4 = "The quick brown fox jumps over the lazy dog\n123"; char s[] = "The quick brown fox jumps over the lazy dog\n" "The quick brown fox jumps over the lazy dog\n" "The quick brown fox jumps over the lazy dog\n" "The quick brown fox jumps over the lazy dog\n" "The quick brown fox jumps over the lazy dog\n" "The quick brown fox jumps over the lazy dog\n" "The quick brown fox jumps over the lazy dog\n" "The quick brown fox jumps over the lazy dog\n"; char *id4 = "over"; char *id128 = "The_quick_brown_fox_jumps_over_the_lazy_dog" "The_quick_brown_fox_jumps_over_the_lazy_dog" "The_quick_brown_fox_jumps_over_the_lazy_do"; #if 1 int i = 1000000; #if 0 printf("%x %x\n", hash(s+3, 1) & 0xffff, s[3]); printf("%x %x\n", hash(s+3, 1) & 0xffff, s[3]); printf("%x %x %x %x %x %x %x %x %x\n", s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8]); printf("%d\n", strlen(s)); printf("%x %x\n", id4, id128); #endif do { #define Hash whashstr #define Hash aphash #if 0 idhash(id128); #else { unsigned char c, *p; p = id128; do c = *++p; while (isalunum(c)); hash(id128, (char*)p - id128); } #endif } while (--i); #else int i = 1000000; int j = 0; do { j += strlen(id128); } while (--i); return j; printf("%d %d\n", j, strlen(s)); #endif #if 0 puts("done\n"); printf("%x %x %x %x %x %x %x %x %x\n", s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8]); printf("%d\n", strlen(s)); printf("%x %x\n", hash(s+0, 4) & 0xffff, s[3]); printf("%d\n", hash(s+0, 4) & 0xffff); printf("%x\n", hash(s+0, 4) & 0xffff); printf("%x %x\n", hash(s+0, 4) & 0xffff, s[3]); printf("%x %x\n", hash(s0+0, 4) & 0xffff, s0[3]); printf("%x\n", hash(s1+1, 4) & 0xffff); printf("%x\n", hash(s2+2, 4) & 0xffff); printf("%x\n", hash(s3+3, 4) & 0xffff); printf("%x\n", hash(s4+0, 4) & 0xffff); #endif }