1 // Test driver for text collection
5 #include "HeapProfiler.h"
11 #include "TextCollection.h"
12 using SXSI::TextCollection;
14 void printDocumentResult(TextCollection::document_result dr)
16 TextCollection::document_result::iterator it;
17 printf("document result:");
18 for (it = dr.begin(); it != dr.end(); ++it)
24 void printFullResult(TextCollection::full_result fr)
26 TextCollection::full_result::iterator it;
27 printf("full result:");
28 for (it = fr.begin(); it != fr.end(); ++it)
29 printf(" (%i, %lu)", (*it).first, (*it).second);
40 int heap_base = HeapProfiler::GetHeapConsumption ();
41 std::cerr << "Initial heap usage : " << heap_base << "\n";
42 TextCollection *csa = TextCollection::InitTextCollection(5);
43 heap_base = HeapProfiler::GetHeapConsumption ();
44 std::cerr << "Heap usage after InitTextCollection : " << heap_base << "\n";
47 while (not(cin.eof())){
49 data = (uchar *) str.c_str();
50 csa->InsertText(data);
55 std::cerr << "Inserted : " << i << " strings\n";
56 std::cerr << "Number of bytes inserted : " << j << "b \n";
57 std::cerr << "Heap usage used for strings: " << HeapProfiler::GetHeapConsumption() - heap_base
59 std::cerr << "Ratio is : " << (float) (HeapProfiler::GetHeapConsumption() - heap_base) / ((float) j) <<"\n";
65 std::cerr << "Creating new text collection with " << i << " strings (total " << j/1024 << " kb)\n";
66 std::cerr << "Before MakeStatic() [press enter]\n";
68 std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;
70 std::cerr << "After MakeStatic() [press enter]\n";
72 std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;
74 std::cerr << "After Delete [press enter]\n";
75 std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;