bench.c
sima/lhash/bench.c · 1.8 KB
From the archive 970706-sima.tgz
Download the archive « Back to the archive contents
#include <stdio.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";
#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));
#endif
do {
#define Hash whashstr
#define Hash aphash
hash(s+0, 4);
} while (--i);
#else
int i = 1000000;
int j = 0;
do {
j += strlen(s);
} while (--i);
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
}