X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=testTextCollection.cpp;fp=testTextCollection.cpp;h=dd37ff11ca02e3485cc1426c7aa503284a99c048;hb=eb04a05de55af8957aea1353d21b5e5b98bd1006;hp=d89a3285409064d2e5aaf2464020208e72131810;hpb=56d77631b00f8622c211db6721cb087a5d29f0e2;p=SXSI%2FTextCollection.git diff --git a/testTextCollection.cpp b/testTextCollection.cpp index d89a328..dd37ff1 100644 --- a/testTextCollection.cpp +++ b/testTextCollection.cpp @@ -1,5 +1,7 @@ // Test driver for text collection #include +#include +#include "HeapProfiler.h" using std::cout; using std::endl; @@ -28,47 +30,23 @@ void printFullResult(TextCollection::full_result fr) int main() { - uchar *text = (uchar*) "acabab"; - TextCollection *csa = TextCollection::InitTextCollection(1); - csa->InsertText(text); - text = (uchar*) "abaca"; - csa->InsertText(text); - text = (uchar*) "abacb"; - csa->InsertText(text); - - csa->MakeStatic(); -// FILE *pFile = fopen ( "mysave.txt" , "rb" ); -// csa->Load(pFile); - - text = csa->GetText(0); - cout << "Text 0: \"" << text << "\"" << endl; - delete [] text; - text = csa->GetText(1); - cout << "Text 1: \"" << text << "\"" << endl; - delete [] text; - text = csa->GetText(2); - cout << "Text 2: \"" << text << "\"" << endl; - delete [] text; - - text = csa->GetText(2, 2, 4); - cout << "Substring of Text 3: \"" << text << "\"" << endl; - delete [] text; - - printf("n:o contains: %u\n", csa->CountContains((uchar *)"ac")); - printf("n:o suffix: %u\n", csa->CountSuffix((uchar *)"b")); - printf("n:o equal: %u\n", csa->CountEqual((uchar *)"acabab")); - printf("is equal: %u\n", csa->IsEqual((uchar *)"abacb")); - - TextCollection::document_result dr; - dr = csa->Contains((uchar*)"ab"); - printDocumentResult(dr); - - TextCollection::full_result fr; - fr = csa->FullContains((uchar *)"ab"); - printFullResult(fr); - -// FILE *pFile2 = fopen ( "mysave.txt" , "wb" ); -// csa->Save(pFile2); - - delete csa; + std::string kbd; + uchar * str = (uchar*) ""; + + TextCollection *csa = TextCollection::InitTextCollection(64); + for(int i = 0; i<1000000; i++){ + csa->InsertText(str); + }; + std::cerr << "Before MakeStatic() [press enter]\n"; + std::cin >> kbd; + std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl; + csa->MakeStatic(); + std::cerr << "After MakeStatic() [press enter]\n"; + std::cin >> kbd; + std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl; + delete csa; + std::cerr << "After Delete [press enter]\n"; + std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl; + std::cin >> kbd; + return 0; }