1 // Test driver for text collection
12 static struct timeval t1;
13 static struct timeval t2;
15 #define STARTTIMER() (gettimeofday(&t1,NULL))
16 #define STOPTIMER() (gettimeofday(&t2,NULL))
17 #define GETTIME() (((t2.tv_sec - t1.tv_sec) * 1000000.0 + (t2.tv_usec - t1.tv_usec))/1000.0)
21 #include "TextCollection.h"
22 using SXSI::TextCollection;
24 int main(int argc, char**argv)
28 unsigned int max_str = 0;
29 unsigned int num_str = 0;
32 string words[] = { "abcd", "abc", "mirrors", "attires", "mature",
33 "rescue", "such", "embrace", "shipping", "ae",
34 "preventions", "ab", "fe", "w" };
38 TextCollection *csa = TextCollection::InitTextCollection(64);
42 std::cerr << "Filling collection\n";
43 // read only 100000 strings
44 while (not(cin.eof()) && num_str < 100000 ){
45 getline(cin,str); // Read line by line.
46 if (str.compare("----------") == 0){
47 csa->InsertText((unsigned char*) buffer.c_str());
49 if (num_str % 10000 == 0){
52 std::cerr << "Added " << num_str << " strings in "
58 if (max_str < buffer.size())
59 max_str = buffer.size();
66 std::cerr << "Calling MakeStatic()\n";
70 std::cerr << "Statistics: " << num_str << " strings, " << max_str << " = max length\n";
73 TextCollection::document_result res;
74 for (unsigned int i = 0; i < (sizeof(words)/sizeof(char*)) ; i++){
77 is = csa->IsContains((unsigned char*) words[i].c_str());
81 std::cerr << is << ", " << time << ", ";
85 count = csa->Count((unsigned char*) words[i].c_str());
89 std::cerr << count << ", " << time << ", ";
93 count = csa->CountContains((unsigned char*) words[i].c_str());
97 std::cerr << count << ", " << time << ", ";
101 res = csa->Contains((unsigned char*) words[i].c_str());
105 std::cerr << time << "\n";