12 void hit_fn(char *buf)
15 printf("hit[%d]=[%5.5s]\n",hits,buf);
21 /* a simple harness to test the above */
22 int main(int argc,char *argv[])
32 printf("Usage: bmg string|string|string... file\n");
38 fd = open(fname,O_RDONLY);
40 printf("couldn't open %s\n",fname);
43 len = lseek(fd,0,SEEK_END);
45 buf = (char *)malloc(len);
47 printf("failed to alloc buffer\n");
50 len = read(fd,buf,len);
52 printf("Loaded %d bytes\n",len);
54 gettimeofday(&t1,NULL);
55 bmg_build_table(target,NULL,0);
56 gettimeofday(&t2,NULL);
57 printf("Table build took %ld msecs\n",
58 (t2.tv_sec-t1.tv_sec)*1000 + (t2.tv_usec-t1.tv_usec)/1000);
60 gettimeofday(&t1,NULL);
61 bmg_search(buf,len,hit_fn);
62 gettimeofday(&t2,NULL);
63 printf("Search took %ld msec\n",
64 (t2.tv_sec-t1.tv_sec)*1000 + (t2.tv_usec-t1.tv_usec)/1000);
65 printf("Got %d hits\n",hits);