3 // defines concurrent access to map::nonconcurrent_iterator::Sequence::TValue::nAccess field
5 #include "map2/map_find_int.h"
7 // find int test in map<int> in mutithreaded mode
9 CPPUNIT_TEST_SUITE_REGISTRATION( Map_find_int );
11 size_t Map_find_int::c_nThreadCount = 8 ; // thread count
12 size_t Map_find_int::c_nMapSize = 20000000 ; // map size (count of searching item)
13 size_t Map_find_int::c_nPercentExists = 50 ; // percent of existing keys in searching sequence
14 size_t Map_find_int::c_nPassCount = 2;
15 size_t Map_find_int::c_nMaxLoadFactor = 8 ; // maximum load factor
16 bool Map_find_int::c_bPrintGCState = true;
18 void Map_find_int::generateSequence()
20 size_t nPercent = c_nPercentExists;
24 else if ( nPercent < 1 )
29 m_Arr.resize( c_nMapSize );
30 for ( size_t i = 0; i < c_nMapSize; ++i ) {
31 m_Arr[i].nKey = i * 13;
32 m_Arr[i].bExists = CppUnitMini::Rand( 100 ) <= nPercent;
33 if ( m_Arr[i].bExists )
36 std::random_shuffle( m_Arr.begin(), m_Arr.end() );
39 void Map_find_int::initTestSequence()
41 CPPUNIT_MSG( "Generating test data...");
44 CPPUNIT_MSG( " Duration=" << timer.duration() );
45 CPPUNIT_MSG( "Map size=" << m_nRealMapSize << " find key loop=" << m_Arr.size() << " (" << c_nPercentExists << "% success)" );
46 CPPUNIT_MSG( "Thread count=" << c_nThreadCount << " Pass count=" << c_nPassCount );
48 m_bSequenceInitialized = true;
51 void Map_find_int::setUpParams( const CppUnitMini::TestCfg& cfg )
53 c_nThreadCount = cfg.getSizeT("ThreadCount", c_nThreadCount );
54 c_nMapSize = cfg.getSizeT("MapSize", c_nMapSize);
55 c_nPercentExists = cfg.getSizeT("PercentExists", c_nPercentExists);
56 c_nPassCount = cfg.getSizeT("PassCount", c_nPassCount);
57 c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor);
58 c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState );
61 void Map_find_int::myRun(const char *in_name, bool invert /*= false*/)
63 setUpParams( m_Cfg.get( "Map_find_int" ));
65 run_MichaelMap(in_name, invert);
66 run_SplitList(in_name, invert);
67 run_SkipListMap(in_name, invert);
68 run_EllenBinTreeMap(in_name, invert);
69 run_BronsonAVLTreeMap(in_name, invert);
70 run_StripedMap(in_name, invert);
71 run_RefinableMap(in_name, invert);
72 run_CuckooMap(in_name, invert);
73 run_StdMap(in_name, invert);