Refactored Map_InsDelFind MT-test
[libcds.git] / tests / unit / map2 / map_insdelfind.cpp
1 //$$CDS-header$$
2
3 #include "map2/map_insdelfind.h"
4 #include <cds/os/topology.h>
5
6 namespace map2 {
7     CPPUNIT_TEST_SUITE_REGISTRATION( Map_InsDelFind );
8
9     void Map_InsDelFind::setUpParams( const CppUnitMini::TestCfg& cfg )
10     {
11         c_nMapSize = cfg.getSizeT("InitialMapSize", c_nMapSize );
12         c_nThreadCount = cfg.getSizeT("ThreadCount", c_nThreadCount );
13         c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor );
14         c_nInsertPercentage = cfg.getUInt("InsertPercentage", c_nInsertPercentage );
15         c_nDeletePercentage = cfg.getUInt("DeletePercentage", c_nDeletePercentage );
16         c_nDuration = cfg.getUInt("Duration", c_nDuration );
17         c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState );
18
19         c_nCuckooInitialSize = cfg.getSizeT("CuckooInitialSize", c_nCuckooInitialSize);
20         c_nCuckooProbesetSize = cfg.getSizeT("CuckooProbesetSize", c_nCuckooProbesetSize);
21         c_nCuckooProbesetThreshold = cfg.getSizeT("CuckooProbesetThreshold", c_nCuckooProbesetThreshold);
22
23         c_nMultiLevelMap_HeadBits = cfg.getSizeT("MultiLevelMapHeadBits", c_nMultiLevelMap_HeadBits);
24         c_nMultiLevelMap_ArrayBits = cfg.getSizeT("MultiLevelMapArrayBits", c_nMultiLevelMap_ArrayBits);
25
26         if ( c_nThreadCount == 0 )
27             c_nThreadCount = std::thread::hardware_concurrency() * 2;
28
29         CPPUNIT_ASSERT( c_nInsertPercentage + c_nDeletePercentage <= 100 );
30
31         actions * pFirst = m_arrShuffle;
32         actions * pLast = m_arrShuffle + c_nInsertPercentage;
33         std::fill( pFirst, pLast, do_insert );
34         pFirst = pLast;
35         pLast += c_nDeletePercentage;
36         std::fill( pFirst, pLast, do_delete );
37         pFirst = pLast;
38         pLast = m_arrShuffle + sizeof(m_arrShuffle)/sizeof(m_arrShuffle[0]);
39         std::fill( pFirst, pLast, do_find );
40         shuffle( m_arrShuffle, pLast );
41     }
42 } // namespace map2