9ed39bdf404ef951a8096fa7b13cf267bdde4a9a
[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.reserve( nSize );
22
23         nSize = 0;
24         for ( size_t i = 0; i < nSize && i < arrString.size(); ++i ) {
25         bool bExists = CppUnitMini::Rand( 100 ) <= nPercent;
26             m_Arr.push_back( { &arrString.at(i), bExists } );
27             if ( 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...\n");
53         cds::OS::Timer    timer;
54         generateSequence();
55         CPPUNIT_MSG( "   Duration=" << timer.duration() << "\n" );
56
57     }
58 } // namespace map2