mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
HashTable performance: find(), found() check nElmts_ instead of tableSize_
- much better performance on empty tables (4-6x speedup), neutral performance change on filled tables. Since tableSize_ is non-zero when nElmts_ is, there is no modulus zero problem.
This commit is contained in:
@ -32,6 +32,7 @@ Description
|
||||
#include "boolList.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "HashSet.H"
|
||||
#include "StaticHashTable.H"
|
||||
#include "cpuTime.H"
|
||||
#include <vector>
|
||||
|
||||
@ -55,11 +56,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
labelHashSet emptyHash;
|
||||
labelHashSet fullHash(1000);
|
||||
for(label i = 0; i < n; i++)
|
||||
for (label i = 0; i < n; i++)
|
||||
{
|
||||
fullHash.insert(i);
|
||||
}
|
||||
|
||||
// don't use fullStaticHash, it's too slow
|
||||
StaticHashTable<nil, label, Hash<label> > emptyStaticHash;
|
||||
|
||||
cpuTime timer;
|
||||
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
@ -235,6 +239,22 @@ int main(int argc, char *argv[])
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read empty static hash
|
||||
sum = 0;
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
forAll(unpacked, i)
|
||||
{
|
||||
sum += emptyStaticHash.found(i);
|
||||
}
|
||||
}
|
||||
Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
|
||||
|
||||
Info<< "Starting write tests" << endl;
|
||||
|
||||
//
|
||||
// Write
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user