Renamed MultiLevelHashSet/Map to FeldmanHashSet/Map
[libcds.git] / tests / unit / map2 / map_find_string.cpp
1 //$$CDS-header$$
2
3 #include "map2/map_find_string.h"
4
5 namespace map2 {
6     CPPUNIT_TEST_SUITE_REGISTRATION( Map_find_string );
7
8     void Map_find_string::generateSequence()
9     {
10         size_t nPercent = c_nPercentExists;
11
12         if ( nPercent > 100 )
13             nPercent = 100;
14         else if ( nPercent < 1 )
15             nPercent = 1;
16
17         std::vector<std::string> const& arrString = CppUnitMini::TestCase::getTestStrings();
18         size_t nSize = arrString.size();
19         if ( nSize > c_nMapSize )
20             nSize = c_nMapSize;
21         m_Arr.resize( nSize );
22
23         nSize = 0;
24         for ( size_t i = 0; i < nSize; ++i ) {
25             m_Arr[i].pKey = &( arrString[i] );
26             m_Arr[i].bExists = CppUnitMini::Rand( 100 ) <= nPercent;
27             if ( m_Arr[i].bExists )
28                 ++nSize;
29         }
30         c_nMapSize = nSize;
31     }
32
33     void Map_find_string::setUpParams( const CppUnitMini::TestCfg& cfg )
34     {
35         c_nThreadCount = cfg.getSizeT("ThreadCount", c_nThreadCount );
36         c_nMapSize = cfg.getSizeT("MapSize", c_nMapSize);
37         c_nPercentExists = cfg.getSizeT("PercentExists", c_nPercentExists);
38         c_nPassCount = cfg.getSizeT("PassCount", c_nPassCount);
39         c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor);
40         c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState );
41
42         c_nCuckooInitialSize = cfg.getSizeT("CuckooInitialSize", c_nCuckooInitialSize);
43         c_nCuckooProbesetSize = cfg.getSizeT("CuckooProbesetSize", c_nCuckooProbesetSize);
44         c_nCuckooProbesetThreshold = cfg.getSizeT("CuckooProbesetThreshold", c_nCuckooProbesetThreshold);
45
46         c_nFeldmanMap_HeadBits = cfg.getSizeT("FeldmanMapHeadBits", c_nFeldmanMap_HeadBits);
47         c_nFeldmanMap_ArrayBits = cfg.getSizeT("FeldmanMapArrayBits", c_nFeldmanMap_ArrayBits);
48
49         if ( c_nThreadCount == 0 )
50             c_nThreadCount = std::thread::hardware_concurrency();
51
52         CPPUNIT_MSG( "Generating test data...");
53         cds::OS::Timer    timer;
54         generateSequence();
55         CPPUNIT_MSG( "   Duration=" << timer.duration() );
56         CPPUNIT_MSG( "Map size=" << c_nMapSize << " find key loop=" << m_Arr.size() << " (" << c_nPercentExists << "% success)" );
57         CPPUNIT_MSG( "Thread count=" << c_nThreadCount << " Pass count=" << c_nPassCount );
58
59     }
60 } // namespace map2