Reorganized map2 unit test to reduce compiling time and memory
[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     size_t  Map_InsDelFind::c_nInitialMapSize = 500000;
10     size_t  Map_InsDelFind::c_nThreadCount = 8;
11     size_t  Map_InsDelFind::c_nMaxLoadFactor = 8;
12     unsigned int Map_InsDelFind::c_nInsertPercentage = 5;
13     unsigned int Map_InsDelFind::c_nDeletePercentage = 5;
14     unsigned int Map_InsDelFind::c_nDuration = 30;
15     bool    Map_InsDelFind::c_bPrintGCState = true;
16
17     void Map_InsDelFind::setUpParams( const CppUnitMini::TestCfg& cfg )
18     {
19         c_nInitialMapSize = cfg.getSizeT("InitialMapSize", c_nInitialMapSize );
20         c_nThreadCount = cfg.getSizeT("ThreadCount", c_nThreadCount );
21         c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor );
22         c_nInsertPercentage = cfg.getUInt("InsertPercentage", c_nInsertPercentage );
23         c_nDeletePercentage = cfg.getUInt("DeletePercentage", c_nDeletePercentage );
24         c_nDuration = cfg.getUInt("Duration", c_nDuration );
25         c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState );
26
27         if ( c_nThreadCount == 0 )
28             c_nThreadCount = cds::OS::topology::processor_count() * 2;
29
30         CPPUNIT_ASSERT( c_nInsertPercentage + c_nDeletePercentage <= 100 );
31
32         actions * pFirst = m_arrShuffle;
33         actions * pLast = m_arrShuffle + c_nInsertPercentage;
34         std::fill( pFirst, pLast, do_insert );
35         pFirst = pLast;
36         pLast += c_nDeletePercentage;
37         std::fill( pFirst, pLast, do_delete );
38         pFirst = pLast;
39         pLast = m_arrShuffle + sizeof(m_arrShuffle)/sizeof(m_arrShuffle[0]);
40         std::fill( pFirst, pLast, do_find );
41         std::random_shuffle( m_arrShuffle, pLast );
42     }
43
44     void Map_InsDelFind::myRun(const char *in_name, bool invert /*= false*/)
45     {
46         setUpParams( m_Cfg.get( "Map_InsDelFind" ));
47
48         run_MichaelMap(in_name, invert);
49         run_SplitList(in_name, invert);
50         run_SkipListMap(in_name, invert);
51         run_EllenBinTreeMap(in_name, invert);
52         run_BronsonAVLTreeMap(in_name, invert);
53         run_StripedMap(in_name, invert);
54         run_RefinableMap(in_name, invert);
55         run_CuckooMap(in_name, invert);
56         run_StdMap(in_name, invert);
57
58         endTestCase();
59     }
60 } // namespace map2