7c65caf29cdee2cf18d7e52e3bc2b32079b9b7a9
[libcds.git] / tests / unit / map2 / map_delodd.cpp
1 //$$CDS-header$$
2
3 #include "map2/map_delodd.h"
4
5 namespace map2 {
6     CPPUNIT_TEST_SUITE_REGISTRATION( Map_DelOdd );
7
8     size_t  Map_DelOdd::c_nMapSize = 1000000         ;  // max map size
9     size_t  Map_DelOdd::c_nInsThreadCount = 4        ;  // insert thread count
10     size_t  Map_DelOdd::c_nDelThreadCount = 4        ;  // delete thread count
11     size_t  Map_DelOdd::c_nExtractThreadCount = 4    ;  // extract thread count
12     size_t  Map_DelOdd::c_nMaxLoadFactor = 8         ;  // maximum load factor
13     bool    Map_DelOdd::c_bPrintGCState = true;
14
15     void Map_DelOdd::setUpParams( const CppUnitMini::TestCfg& cfg ) {
16         c_nMapSize = cfg.getULong("MapSize", static_cast<unsigned long>(c_nMapSize) );
17         c_nInsThreadCount = cfg.getULong("InsThreadCount", static_cast<unsigned long>(c_nInsThreadCount) );
18         c_nDelThreadCount = cfg.getULong("DelThreadCount", static_cast<unsigned long>(c_nDelThreadCount) );
19         c_nExtractThreadCount = cfg.getULong("ExtractThreadCount", static_cast<unsigned long>(c_nExtractThreadCount) );
20         c_nMaxLoadFactor = cfg.getULong("MaxLoadFactor", static_cast<unsigned long>(c_nMaxLoadFactor) );
21         c_bPrintGCState = cfg.getBool("PrintGCStateFlag", true );
22
23         if ( c_nInsThreadCount == 0 )
24             c_nInsThreadCount = cds::OS::topology::processor_count();
25         if ( c_nDelThreadCount == 0 && c_nExtractThreadCount == 0 ) {
26             c_nExtractThreadCount = cds::OS::topology::processor_count() / 2;
27             c_nDelThreadCount = cds::OS::topology::processor_count() - c_nExtractThreadCount;
28         }
29
30         m_arrInsert.resize( c_nMapSize );
31         m_arrRemove.resize( c_nMapSize );
32         for ( size_t i = 0; i < c_nMapSize; ++i ) {
33             m_arrInsert[i] = i;
34             m_arrRemove[i] = i;
35         }
36         shuffle( m_arrInsert.begin(), m_arrInsert.end() );
37         shuffle( m_arrRemove.begin(), m_arrRemove.end() );
38     }
39
40     void Map_DelOdd::myRun(const char *in_name, bool invert /*= false*/)
41     {
42         setUpParams( m_Cfg.get( "Map_DelOdd" ));
43
44         run_MichaelMap(in_name, invert);
45         run_SplitList(in_name, invert);
46         run_SkipListMap(in_name, invert);
47         run_EllenBinTreeMap(in_name, invert);
48         run_BronsonAVLTreeMap(in_name, invert);
49         //run_StripedMap(in_name, invert);
50         //run_RefinableMap(in_name, invert);
51         run_CuckooMap(in_name, invert);
52         //run_StdMap(in_name, invert);
53
54         endTestCase();
55     }
56
57 } // namespace map2