/*
This file is a part of libcds - Concurrent Data Structures library
- (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
public:
static size_t s_nMapSize; // initial map size
static size_t s_nThreadCount; // thread count
+ static size_t s_nPassCount; // pass count
+
+ static size_t s_nBronsonAVLTreeMapPassCount;
+
+ static size_t s_nHpEllenBinTreeMapPassCount;
+ static size_t s_nHpFeldmanPassCount;
+ static size_t s_nHpMichaelMapPassCount;
+ static size_t s_nHpSkipListMapPassCount;
+ static size_t s_nHpSplitListMapPassCount;
+
+ static size_t s_nRcuEllenBinTreeMapPassCount;
+ static size_t s_nRcuFeldmanPassCount;
+ static size_t s_nRcuMichaelMapPassCount;
+ static size_t s_nRcuSkipListMapPassCount;
+ static size_t s_nRcuSplitListMapPassCount;
+
static size_t s_nMaxLoadFactor; // maximum load factor
static unsigned int s_nInsertPercentage;
static unsigned int s_nDeletePercentage;
size_t const nNormalize = size_t(-1) / ( s_nMapSize * 2 );
size_t nRand = 0;
- while ( !time_elapsed() ) {
+ for (size_t pCount = 0; pCount < s_nPassCount; pCount++) {
+ nRand = cds::bitop::RandXorShift( nRand );
+ size_t key = nRand / nNormalize;
nRand = cds::bitop::RandXorShift( nRand );
- size_t n = nRand / nNormalize;
+ size_t value = nRand / nNormalize;
switch ( s_arrShuffle[i] ) {
case do_find:
- if ( rMap.contains( n ))
+ if ( rMap.contains( key ))
++m_nFindSuccess;
else
++m_nFindFailed;
break;
case do_insert:
- if ( n % 2 ) {
- if ( rMap.insert( n, n ))
+ if ( key % 2 ) {
+ if ( rMap.insert( key, value ))
++m_nInsertSuccess;
else
++m_nInsertFailed;
}
else {
- if ( rMap.update( n, update_functor(), true ).first )
+ if ( rMap.update( key, update_functor(), true ).first )
++m_nInsertSuccess;
else
++m_nInsertFailed;
}
break;
case do_delete:
- if ( rMap.erase( n ))
+ if ( rMap.erase( key ))
++m_nDeleteSuccess;
else
++m_nDeleteFailed;
void do_test( Map& testMap )
{
typedef Worker<Map> worker;
-
- // fill map - only odd number
- {
- std::vector<size_t> arr;
- arr.reserve( s_nMapSize );
- for ( size_t i = 0; i < s_nMapSize; ++i )
- arr.push_back( i * 2 + 1);
- shuffle( arr.begin(), arr.end() );
- for ( size_t i = 0; i < s_nMapSize; ++i )
- testMap.insert( arr[i], arr[i] );
- }
-
cds_test::thread_pool& pool = get_pool();
pool.add( new worker( pool, testMap ), s_nThreadCount );
- propout() << std::make_pair( "thread_count", s_nThreadCount )
- << std::make_pair( "insert_percentage", s_nInsertPercentage )
- << std::make_pair( "delete_percentage", s_nDeletePercentage )
- << std::make_pair( "map_size", s_nMapSize );
-
- std::chrono::milliseconds duration = pool.run( std::chrono::seconds( s_nDuration ));
-
- propout() << std::make_pair( "duration", duration );
+ std::chrono::milliseconds duration = pool.run();
size_t nInsertSuccess = 0;
size_t nInsertFailed = 0;
<< std::make_pair( "delete_failed", nDeleteFailed )
<< std::make_pair( "find_success", nFindSuccess )
<< std::make_pair( "find_failed", nFindFailed )
- << std::make_pair( "finish_map_size", testMap.size() );
+ << std::make_pair( "finish_map_size", testMap.size());
{
- ASSERT_TRUE( std::chrono::duration_cast<std::chrono::seconds>(duration).count() > 0 );
size_t nTotalOps = nInsertSuccess + nInsertFailed + nDeleteSuccess + nDeleteFailed + nFindSuccess + nFindFailed;
propout() << std::make_pair( "avg_speed", nTotalOps / std::chrono::duration_cast<std::chrono::seconds>( duration ).count());
}
Map testMap( *this );
do_test( testMap );
}
+
+ template <class Map>
+ void run_bronson_avl_tree() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nBronsonAVLTreeMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_ellen_bin_tree_hp() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nHpEllenBinTreeMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_skip_list_hp() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nHpSkipListMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_feldman_hp() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nHpFeldmanPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_ellen_bin_tree_rcu() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nRcuEllenBinTreeMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_skip_list_rcu() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nRcuSkipListMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_feldman_rcu() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nRcuFeldmanPassCount;
+ run_test<Map>();
+ }
};
class Map_InsDelFind_LF: public Map_InsDelFind
Map_InsDelFind::run_test<Map>();
}
+ template <class Map>
+ void run_michael_hp() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nHpMichaelMapPassCount;
+ Map_InsDelFind_LF::run_test<Map>();
+ }
+
+ template <class Map>
+ void run_split_list_hp() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nHpSplitListMapPassCount;
+ Map_InsDelFind_LF::run_test<Map>();
+ }
+
+ template <class Map>
+ void run_michael_rcu() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nRcuMichaelMapPassCount;
+ Map_InsDelFind_LF::run_test<Map>();
+ }
+
+ template <class Map>
+ void run_split_list_rcu() {
+ Map_InsDelFind::s_nPassCount =
+ Map_InsDelFind::s_nRcuSplitListMapPassCount;
+ Map_InsDelFind_LF::run_test<Map>();
+ }
+
static std::vector<size_t> get_load_factors();
};