| 206 | |
| 207 | template< class Stack> |
| 208 | void analyze( Stack& /*stack*/ ) |
| 209 | { |
| 210 | cds_test::thread_pool& pool = get_pool(); |
| 211 | |
| 212 | size_t nPushError = 0; |
| 213 | size_t nPopEmpty = 0; |
| 214 | size_t nPopCount = 0; |
| 215 | size_t arrVal[c_nValArraySize]; |
| 216 | memset( arrVal, 0, sizeof( arrVal )); |
| 217 | size_t nDirtyPop = 0; |
| 218 | |
| 219 | for ( size_t threadNo = 0; threadNo < pool.size(); ++threadNo ) { |
| 220 | cds_test::thread& thread = pool.get( threadNo ); |
| 221 | if ( thread.type() == producer_thread ) { |
| 222 | Producer<Stack>& producer = static_cast<Producer<Stack>&>( thread ); |
| 223 | |
| 224 | nPushError += producer.m_nPushError; |
| 225 | for ( size_t i = 0; i < c_nValArraySize; ++i ) |
| 226 | arrVal[i] += producer.m_arrPush[i]; |
| 227 | } |
| 228 | else { |
| 229 | ASSERT_EQ( thread.type(), consumer_thread ); |
| 230 | Consumer<Stack>& consumer = static_cast<Consumer<Stack>&>(thread); |
| 231 | |
| 232 | nPopEmpty += consumer.m_nPopEmpty; |
| 233 | nPopCount += consumer.m_nPopCount; |
| 234 | nDirtyPop += consumer.m_nDirtyPop; |
| 235 | for ( size_t i = 0; i < c_nValArraySize; ++i ) |
| 236 | arrVal[i] -= consumer.m_arrPop[i]; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | EXPECT_EQ( nPopCount, s_nStackSize ); |
| 241 | EXPECT_EQ( nDirtyPop, 0u ); |
| 242 | |
| 243 | for ( size_t i = 0; i < sizeof( arrVal ) / sizeof( arrVal[0] ); ++i ) { |
| 244 | EXPECT_EQ( arrVal[i], 0u ); |
| 245 | } |
| 246 | |
| 247 | propout() << std::make_pair( "push_count", s_nStackSize ) |
| 248 | << std::make_pair( "push_error", nPushError ) |
| 249 | << std::make_pair( "pop_empty", nPopEmpty ) |
| 250 | << std::make_pair( "dirty_pop", nDirtyPop ) |
| 251 | ; |
| 252 | } |
| 253 | }; |
| 254 | |
| 255 | CDSSTRESS_TreiberStack( stack_push_pop ) |