STYLE: compilation of some unit tests

This commit is contained in:
Mark Olesen
2017-10-26 23:59:18 +02:00
parent 16e75d8475
commit 8ec64d8128
6 changed files with 196 additions and 85 deletions

View File

@ -35,12 +35,20 @@ Description
using namespace Foam;
template<class T>
Ostream& printInfo(Ostream& os, const HashTable<T, T, Hash<T>>& ht)
{
os << " (size " << ht.size() << " capacity " << ht.capacity() << ") ";
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
const label nLoops = 30;
const label nLoops = 300;
const label nBase = 100000;
const label nSize = nLoops * nBase;
@ -52,17 +60,18 @@ int main(int argc, char *argv[])
// StaticHashTable<label, label, Hash<label>> map(2 * nSize);
HashTable<label, label, Hash<label>> map(2 * nSize);
Info<< "Constructed map of size: " << nSize
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
<< " " << timer.cpuTimeIncrement() << " s\n\n";
Info<< "Constructed map of size: " << nSize;
printInfo(Info, map);
Info<< timer.cpuTimeIncrement() << " s\n\n";
for (label i = 0; i < nSize; i++)
{
map.insert(i, i);
}
Info<< "Inserted " << nSize << " elements"
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
<< timer.cpuTimeIncrement() << " s\n";
Info<< "Inserted " << nSize << " elements";
printInfo(Info, map);
Info<< timer.cpuTimeIncrement() << " s\n\n";
label elemI = 0;
for (label iLoop = 0; iLoop < nLoops; iLoop++)
@ -72,12 +81,14 @@ int main(int argc, char *argv[])
map.erase(elemI++);
}
map.shrink();
Info<< "loop " << iLoop << " - Erased " << nBase << " elements"
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
<< timer.cpuTimeIncrement() << " s\n";
// map.shrink();
Info<< "loop " << iLoop << " - Erased " << nBase << " elements";
printInfo(Info, map);
Info << nl;
}
Info<< timer.cpuTimeIncrement() << " s\n";
return 0;
}