{
public:
static size_t s_nSetSize; // initial set size
+ static size_t s_nPassCount; // initial set size
static size_t s_nThreadCount; // thread count
static size_t s_nMaxLoadFactor; // maximum load factor
static unsigned int s_nInsertPercentage;
unsigned int i = 0;
size_t const nNormalize = size_t(-1) / ( fixture.s_nSetSize * 2);
+ size_t pass_count = fixture.s_nPassCount;
size_t nRand = 0;
- while ( !time_elapsed()) {
+ while ( pass_count-- ) {
nRand = cds::bitop::RandXorShift(nRand);
size_t n = nRand / nNormalize;
switch ( s_arrShuffle[i] ) {
delete [] pInitArr;
}
+ s_nThreadCount = 1;
cds_test::thread_pool& pool = get_pool();
- pool.add( new work_thread( pool, testSet ), s_nThreadCount );
+ std::unique_ptr<work_thread> worker(new work_thread(pool, testSet));
+ worker->test();
propout() << std::make_pair( "thread_count", s_nThreadCount )
<< std::make_pair( "set_size", s_nSetSize )
<< std::make_pair( "delete_percentage", s_nDeletePercentage )
<< std::make_pair( "total_duration", s_nDuration );
- std::chrono::milliseconds duration = pool.run( std::chrono::seconds( s_nDuration ));
-
- propout() << std::make_pair( "duration", duration );
-
size_t nInsertSuccess = 0;
size_t nInsertFailed = 0;
size_t nDeleteSuccess = 0;
size_t nDeleteFailed = 0;
size_t nFindSuccess = 0;
size_t nFindFailed = 0;
- for ( size_t i = 0; i < pool.size(); ++i ) {
- work_thread& thr = static_cast<work_thread&>( pool.get( i ));
- nInsertSuccess += thr.m_nInsertSuccess;
- nInsertFailed += thr.m_nInsertFailed;
- nDeleteSuccess += thr.m_nDeleteSuccess;
- nDeleteFailed += thr.m_nDeleteFailed;
- nFindSuccess += thr.m_nFindSuccess;
- nFindFailed += thr.m_nFindFailed;
- }
+ work_thread &thr = *worker;
+ nInsertSuccess += thr.m_nInsertSuccess;
+ nInsertFailed += thr.m_nInsertFailed;
+ nDeleteSuccess += thr.m_nDeleteSuccess;
+ nDeleteFailed += thr.m_nDeleteFailed;
+ nFindSuccess += thr.m_nFindSuccess;
+ nFindFailed += thr.m_nFindFailed;
propout()
<< std::make_pair( "insert_success", nInsertSuccess )
<< std::make_pair( "find_success", nFindSuccess )
<< std::make_pair( "find_failed", nFindFailed );
- {
- 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());
- }
-
-
testSet.clear();
EXPECT_TRUE( testSet.empty()) << "set size=" << testSet.size();