projects
/
SXSI
/
TextCollection.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RRR coding to BRW
[SXSI/TextCollection.git]
/
testTextCollection.cpp
diff --git
a/testTextCollection.cpp
b/testTextCollection.cpp
index
3add025
..
59b6b43
100644
(file)
--- a/
testTextCollection.cpp
+++ b/
testTextCollection.cpp
@@
-2,13
+2,13
@@
#include <iostream>
#include <cstdlib>
#include <string>
#include <iostream>
#include <cstdlib>
#include <string>
-#include "HeapProfiler.h"
using std::cout;
using std::endl;
using std::cin;
using std::string;
#include "TextCollection.h"
using std::cout;
using std::endl;
using std::cin;
using std::string;
#include "TextCollection.h"
+#include "HeapProfiler.h"
using SXSI::TextCollection;
void printDocumentResult(TextCollection::document_result dr)
using SXSI::TextCollection;
void printDocumentResult(TextCollection::document_result dr)
@@
-37,15
+37,16
@@
int main()
string str;
uchar* data;
int i = 0 ,j = 0;
string str;
uchar* data;
int i = 0 ,j = 0;
- int heap_base = HeapProfiler::GetHeapConsumption
();
+ int heap_base = HeapProfiler::GetHeapConsumption();
std::cerr << "Initial heap usage : " << heap_base << "\n";
std::cerr << "Initial heap usage : " << heap_base << "\n";
- TextCollection *csa = TextCollection::InitTextCollection(5);
+ TextCollection *csa = TextCollection::InitTextCollection(5);
// Avoid small samplerates ;)
heap_base = HeapProfiler::GetHeapConsumption ();
std::cerr << "Heap usage after InitTextCollection : " << heap_base << "\n";
while (not(cin.eof())){
heap_base = HeapProfiler::GetHeapConsumption ();
std::cerr << "Heap usage after InitTextCollection : " << heap_base << "\n";
while (not(cin.eof())){
- getline(cin,str);
+ getline(cin,str); // Read line by line.
+// cin >> str; // Read word by word.
data = (uchar *) str.c_str();
csa->InsertText(data);
i++;
data = (uchar *) str.c_str();
csa->InsertText(data);
i++;
@@
-60,14
+61,22
@@
int main()
};
};
- };
+ };
+
+/* the whole file as one string:
+ uchar *temp = Tools::GetFileContents("data.txt", 0);
+ csa->InsertText(temp);
+ delete [] temp;*/
std::cerr << "Creating new text collection with " << i << " strings (total " << j/1024 << " kb)\n";
std::cerr << "Before MakeStatic() [press enter]\n";
std::cin >> kbd;
std::cerr << "Creating new text collection with " << i << " strings (total " << j/1024 << " kb)\n";
std::cerr << "Before MakeStatic() [press enter]\n";
std::cin >> kbd;
- std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;
+ // This will print the maximum mem usage during construction time:
+ std::cerr << "max heap usage: " << HeapProfiler::GetMaxHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;
csa->MakeStatic();
std::cerr << "After MakeStatic() [press enter]\n";
csa->MakeStatic();
std::cerr << "After MakeStatic() [press enter]\n";
+ // This will print the maximum mem usage during MakeStatic():
+ std::cerr << "max heap usage: " << HeapProfiler::GetMaxHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;
std::cin >> kbd;
std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;
delete csa;
std::cin >> kbd;
std::cerr << "heap usage: " << HeapProfiler::GetHeapConsumption()/(1024*1024) << " Mbytes" << std::endl;
delete csa;