MichaelList, LazyList, MichaelMap:
[libcds.git] / tests / unit / map2 / map_delodd.h
1 //$$CDS-header$$
2
3 #include "cppunit/thread.h"
4 #include "map2/map_type.h"
5 #include <cds/os/topology.h>
6
7 namespace map2 {
8
9 //#   define TEST_MAP(IMPL, C, X)         void C::X() { test<map_type<IMPL, key_type, value_type>::X >(); }
10 //#   define TEST_MAP_DEFAULT_CONSTRUCTIBLE(IMPL, C, X) void C::X() { test_default_constructible<map_type<IMPL, key_type, value_type>::X >(); }
11 //#   define TEST_MAP_EXTRACT(IMPL, C, X) void C::X() { test_extract<map_type<IMPL, key_type, value_type>::X >(); }
12 //#   define TEST_MAP_NOLF(IMPL, C, X)    void C::X() { test_nolf<map_type<IMPL, key_type, value_type>::X >(); }
13 //#   define TEST_MAP_NOLF_EXTRACT(IMPL, C, X) void C::X() { test_nolf_extract<map_type<IMPL, key_type, value_type>::X >(); }
14
15 #   define TEST_CASE(TAG, X)  void X();
16
17     namespace {
18         struct key_thread
19         {
20             size_t  nKey;
21             size_t  nThread;
22
23             key_thread( size_t key, size_t threadNo )
24                 : nKey( key )
25                 , nThread( threadNo )
26             {}
27
28             key_thread()
29             {}
30         };
31     }
32
33     template <>
34     struct cmp<key_thread> {
35         int operator ()(key_thread const& k1, key_thread const& k2) const
36         {
37             if ( k1.nKey < k2.nKey )
38                 return -1;
39             if ( k1.nKey > k2.nKey )
40                 return 1;
41             if ( k1.nThread < k2.nThread )
42                 return -1;
43             if ( k1.nThread > k2.nThread )
44                 return 1;
45             return 0;
46         }
47         int operator ()(key_thread const& k1, size_t k2) const
48         {
49             if ( k1.nKey < k2 )
50                 return -1;
51             if ( k1.nKey > k2 )
52                 return 1;
53             return 0;
54         }
55         int operator ()(size_t k1, key_thread const& k2) const
56         {
57             if ( k1 < k2.nKey )
58                 return -1;
59             if ( k1 > k2.nKey )
60                 return 1;
61             return 0;
62         }
63     };
64
65 } // namespace map2
66
67 namespace std {
68     template <>
69     struct less<map2::key_thread>
70     {
71         bool operator()(map2::key_thread const& k1, map2::key_thread const& k2) const
72         {
73             if ( k1.nKey <= k2.nKey )
74                 return k1.nKey < k2.nKey || k1.nThread < k2.nThread;
75             return false;
76         }
77     };
78
79     template <>
80     struct hash<map2::key_thread>
81     {
82         typedef size_t              result_type;
83         typedef map2::key_thread    argument_type;
84
85         size_t operator()( map2::key_thread const& k ) const
86         {
87             return std::hash<size_t>()(k.nKey);
88         }
89         size_t operator()( size_t k ) const
90         {
91             return std::hash<size_t>()(k);
92         }
93     };
94 } // namespace std
95
96 namespace boost {
97     inline size_t hash_value( map2::key_thread const& k )
98     {
99         return std::hash<size_t>()( k.nKey );
100     }
101
102     template <>
103     struct hash<map2::key_thread>
104     {
105         typedef size_t              result_type;
106         typedef map2::key_thread    argument_type;
107
108         size_t operator()(map2::key_thread const& k) const
109         {
110             return boost::hash<size_t>()( k.nKey );
111         }
112         size_t operator()(size_t k) const
113         {
114             return boost::hash<size_t>()( k );
115         }
116     };
117 } // namespace boost
118
119 namespace map2 {
120
121     class Map_DelOdd: public CppUnitMini::TestCase
122     {
123     public:
124         size_t  c_nInsThreadCount = 4;      // insert thread count
125         size_t  c_nDelThreadCount = 4;      // delete thread count
126         size_t  c_nExtractThreadCount = 4;  // extract thread count
127         size_t  c_nMapSize = 1000000;       // max map size
128         size_t  c_nMaxLoadFactor = 8;       // maximum load factor
129         size_t  c_nMultiLevelMap_HeadBits = 10; // for MultiLevelHashMap - log2(size of head array)
130         size_t  c_nMultiLevelMap_ArrayBits = 8; // for MultiLevelHashMap - log2(size of array node)
131
132         bool    c_bPrintGCState = true;
133
134         size_t  c_nLoadFactor;  // current load factor
135
136     private:
137         std::vector<size_t>     m_arrInsert;
138         std::vector<size_t>     m_arrRemove;
139
140     protected:
141         typedef CppUnitMini::TestCase Base;
142
143         typedef key_thread  key_type;
144         typedef size_t      value_type;
145         typedef std::pair<key_type const, value_type> pair_type;
146
147         atomics::atomic<size_t>      m_nInsThreadCount;
148
149         // Inserts keys from [0..N)
150         template <class Map>
151         class InsertThread: public CppUnitMini::TestThread
152         {
153             Map&     m_Map;
154
155             virtual InsertThread *    clone()
156             {
157                 return new InsertThread( *this );
158             }
159
160             struct ensure_func
161             {
162                 template <typename Q>
163                 void operator()( bool /*bNew*/, Q const& )
164                 {}
165                 template <typename Q, typename V>
166                 void operator()( bool /*bNew*/, Q const&, V& )
167                 {}
168
169                 // MultiLevelHashMap
170                 template <typename Q>
171                 void operator()( Q&, Q*)
172                 {}
173             };
174         public:
175             size_t  m_nInsertSuccess;
176             size_t  m_nInsertFailed;
177
178         public:
179             InsertThread( CppUnitMini::ThreadPool& pool, Map& rMap )
180                 : CppUnitMini::TestThread( pool )
181                 , m_Map( rMap )
182             {}
183             InsertThread( InsertThread& src )
184                 : CppUnitMini::TestThread( src )
185                 , m_Map( src.m_Map )
186             {}
187
188             Map_DelOdd&  getTest()
189             {
190                 return reinterpret_cast<Map_DelOdd&>( m_Pool.m_Test );
191             }
192
193             virtual void init() { cds::threading::Manager::attachThread()   ; }
194             virtual void fini() { cds::threading::Manager::detachThread()   ; }
195
196             virtual void test()
197             {
198                 Map& rMap = m_Map;
199
200                 m_nInsertSuccess =
201                     m_nInsertFailed = 0;
202
203                 std::vector<size_t>& arrData = getTest().m_arrInsert;
204                 for ( size_t i = 0; i < arrData.size(); ++i ) {
205                     if ( rMap.insert( key_type( arrData[i], m_nThreadNo )))
206                         ++m_nInsertSuccess;
207                     else
208                         ++m_nInsertFailed;
209                 }
210
211                 ensure_func f;
212                 for ( size_t i = arrData.size() - 1; i > 0; --i ) {
213                     if ( arrData[i] & 1 ) {
214                         rMap.update( key_type( arrData[i], m_nThreadNo ), f );
215                     }
216                 }
217
218                 getTest().m_nInsThreadCount.fetch_sub( 1, atomics::memory_order_acquire );
219             }
220         };
221
222         struct key_equal {
223             bool operator()( key_type const& k1, key_type const& k2 ) const
224             {
225                 return k1.nKey == k2.nKey;
226             }
227             bool operator()( size_t k1, key_type const& k2 ) const
228             {
229                 return k1 == k2.nKey;
230             }
231             bool operator()( key_type const& k1, size_t k2 ) const
232             {
233                 return k1.nKey == k2;
234             }
235         };
236
237         struct key_less {
238             bool operator()( key_type const& k1, key_type const& k2 ) const
239             {
240                 return k1.nKey < k2.nKey;
241             }
242             bool operator()( size_t k1, key_type const& k2 ) const
243             {
244                 return k1 < k2.nKey;
245             }
246             bool operator()( key_type const& k1, size_t k2 ) const
247             {
248                 return k1.nKey < k2;
249             }
250
251             typedef key_equal equal_to;
252         };
253
254         // Deletes odd keys from [0..N)
255         template <class Map>
256         class DeleteThread: public CppUnitMini::TestThread
257         {
258             Map&     m_Map;
259
260             virtual DeleteThread *    clone()
261             {
262                 return new DeleteThread( *this );
263             }
264         public:
265             size_t  m_nDeleteSuccess;
266             size_t  m_nDeleteFailed;
267
268         public:
269             DeleteThread( CppUnitMini::ThreadPool& pool, Map& rMap )
270                 : CppUnitMini::TestThread( pool )
271                 , m_Map( rMap )
272             {}
273             DeleteThread( DeleteThread& src )
274                 : CppUnitMini::TestThread( src )
275                 , m_Map( src.m_Map )
276             {}
277
278             Map_DelOdd&  getTest()
279             {
280                 return reinterpret_cast<Map_DelOdd&>( m_Pool.m_Test );
281             }
282
283             virtual void init() { cds::threading::Manager::attachThread()   ; }
284             virtual void fini() { cds::threading::Manager::detachThread()   ; }
285
286             virtual void test()
287             {
288                 Map& rMap = m_Map;
289
290                 m_nDeleteSuccess =
291                     m_nDeleteFailed = 0;
292
293                 size_t const nInsThreadCount = getTest().c_nInsThreadCount;
294
295                 for ( size_t pass = 0; pass < 2; pass++ ) {
296                     std::vector<size_t>& arrData = getTest().m_arrRemove;
297                     if ( m_nThreadNo & 1 ) {
298                         for ( size_t k = 0; k < nInsThreadCount; ++k ) {
299                             for ( size_t i = 0; i < arrData.size(); ++i ) {
300                                 if ( arrData[i] & 1 ) {
301                                     if ( rMap.erase_with( arrData[i], key_less() ))
302                                         ++m_nDeleteSuccess;
303                                     else
304                                         ++m_nDeleteFailed;
305                                 }
306                             }
307                             if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
308                                 break;
309                         }
310                     }
311                     else {
312                         for ( size_t k = 0; k < nInsThreadCount; ++k ) {
313                             for ( size_t i = arrData.size() - 1; i > 0; --i ) {
314                                 if ( arrData[i] & 1 ) {
315                                     if ( rMap.erase_with( arrData[i], key_less() ))
316                                         ++m_nDeleteSuccess;
317                                     else
318                                         ++m_nDeleteFailed;
319                                 }
320                             }
321                             if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
322                                 break;
323                         }
324                     }
325                 }
326             }
327         };
328
329         // Deletes odd keys from [0..N)
330         template <class GC, class Map >
331         class ExtractThread: public CppUnitMini::TestThread
332         {
333             Map&     m_Map;
334
335             virtual ExtractThread *    clone()
336             {
337                 return new ExtractThread( *this );
338             }
339         public:
340             size_t  m_nDeleteSuccess;
341             size_t  m_nDeleteFailed;
342
343         public:
344             ExtractThread( CppUnitMini::ThreadPool& pool, Map& rMap )
345                 : CppUnitMini::TestThread( pool )
346                 , m_Map( rMap )
347             {}
348             ExtractThread( ExtractThread& src )
349                 : CppUnitMini::TestThread( src )
350                 , m_Map( src.m_Map )
351             {}
352
353             Map_DelOdd&  getTest()
354             {
355                 return reinterpret_cast<Map_DelOdd&>( m_Pool.m_Test );
356             }
357
358             virtual void init() { cds::threading::Manager::attachThread()   ; }
359             virtual void fini() { cds::threading::Manager::detachThread()   ; }
360
361             virtual void test()
362             {
363                 Map& rMap = m_Map;
364
365                 m_nDeleteSuccess =
366                     m_nDeleteFailed = 0;
367
368                 typename Map::guarded_ptr gp;
369                 size_t const nInsThreadCount = getTest().c_nInsThreadCount;
370
371                 for ( size_t pass = 0; pass < 2; ++pass ) {
372                     std::vector<size_t>& arrData = getTest().m_arrRemove;
373                     if ( m_nThreadNo & 1 ) {
374                         for ( size_t k = 0; k < nInsThreadCount; ++k ) {
375                             for ( size_t i = 0; i < arrData.size(); ++i ) {
376                                 if ( arrData[i] & 1 ) {
377                                     gp = rMap.extract_with( arrData[i], key_less());
378                                     if ( gp )
379                                         ++m_nDeleteSuccess;
380                                     else
381                                         ++m_nDeleteFailed;
382                                     gp.release();
383                                 }
384                             }
385                             if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
386                                 break;
387                         }
388                     }
389                     else {
390                         for ( size_t k = 0; k < nInsThreadCount; ++k ) {
391                             for ( size_t i = arrData.size() - 1; i > 0; --i ) {
392                                 if ( arrData[i] & 1 ) {
393                                     gp = rMap.extract_with( arrData[i], key_less());
394                                     if ( gp )
395                                         ++m_nDeleteSuccess;
396                                     else
397                                         ++m_nDeleteFailed;
398                                     gp.release();
399                                 }
400                             }
401                             if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
402                                 break;
403                         }
404                     }
405                 }
406             }
407         };
408
409         template <class RCU, class Map >
410         class ExtractThread< cds::urcu::gc<RCU>, Map > : public CppUnitMini::TestThread
411         {
412             Map&     m_Map;
413
414             virtual ExtractThread *    clone()
415             {
416                 return new ExtractThread( *this );
417             }
418         public:
419             size_t  m_nDeleteSuccess;
420             size_t  m_nDeleteFailed;
421
422         public:
423             ExtractThread( CppUnitMini::ThreadPool& pool, Map& rMap )
424                 : CppUnitMini::TestThread( pool )
425                 , m_Map( rMap )
426             {}
427             ExtractThread( ExtractThread& src )
428                 : CppUnitMini::TestThread( src )
429                 , m_Map( src.m_Map )
430             {}
431
432             Map_DelOdd&  getTest()
433             {
434                 return reinterpret_cast<Map_DelOdd&>( m_Pool.m_Test );
435             }
436
437             virtual void init() { cds::threading::Manager::attachThread()   ; }
438             virtual void fini() { cds::threading::Manager::detachThread()   ; }
439
440             virtual void test()
441             {
442                 Map& rMap = m_Map;
443
444                 m_nDeleteSuccess =
445                     m_nDeleteFailed = 0;
446
447                 typename Map::exempt_ptr xp;
448                 size_t const nInsThreadCount = getTest().c_nInsThreadCount;
449
450                 std::vector<size_t>& arrData = getTest().m_arrRemove;
451                 if ( m_nThreadNo & 1 ) {
452                     for ( size_t k = 0; k < nInsThreadCount; ++k ) {
453                         for ( size_t i = 0; i < arrData.size(); ++i ) {
454                             if ( arrData[i] & 1 ) {
455                                 if ( Map::c_bExtractLockExternal ) {
456                                     {
457                                         typename Map::rcu_lock l;
458                                         xp = rMap.extract_with( arrData[i], key_less() );
459                                         if ( xp )
460                                             ++m_nDeleteSuccess;
461                                         else
462                                             ++m_nDeleteFailed;
463                                     }
464                                 }
465                                 else {
466                                     xp = rMap.extract_with( arrData[i], key_less() );
467                                     if ( xp )
468                                         ++m_nDeleteSuccess;
469                                     else
470                                         ++m_nDeleteFailed;
471                                 }
472                                 xp.release();
473                             }
474                         }
475                         if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
476                             break;
477                     }
478                 }
479                 else {
480                     for ( size_t k = 0; k < nInsThreadCount; ++k ) {
481                         for ( size_t i = arrData.size() - 1; i > 0; --i ) {
482                             if ( arrData[i] & 1 ) {
483                                 if ( Map::c_bExtractLockExternal ) {
484                                     {
485                                         typename Map::rcu_lock l;
486                                         xp = rMap.extract_with( arrData[i], key_less() );
487                                         if ( xp )
488                                             ++m_nDeleteSuccess;
489                                         else
490                                             ++m_nDeleteFailed;
491                                     }
492                                 }
493                                 else {
494                                     xp = rMap.extract_with( arrData[i], key_less() );
495                                     if ( xp )
496                                         ++m_nDeleteSuccess;
497                                     else
498                                         ++m_nDeleteFailed;
499                                 }
500                                 xp.release();
501                             }
502                         }
503                         if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
504                             break;
505                     }
506                 }
507             }
508         };
509
510     protected:
511         template <class Map>
512         void do_test()
513         {
514             Map  testMap( *this );
515             do_test_with( testMap );
516         }
517
518         template <class Map>
519         void do_test_extract()
520         {
521             Map  testMap( *this );
522             do_test_extract_with( testMap );
523         }
524
525         template <class Map>
526         void do_test_with( Map& testMap )
527         {
528             typedef InsertThread<Map> insert_thread;
529             typedef DeleteThread<Map> delete_thread;
530
531             m_nInsThreadCount.store( c_nInsThreadCount, atomics::memory_order_release );
532
533             CppUnitMini::ThreadPool pool( *this );
534             pool.add( new insert_thread( pool, testMap ), c_nInsThreadCount );
535             pool.add( new delete_thread( pool, testMap ), c_nDelThreadCount ? c_nDelThreadCount : cds::OS::topology::processor_count());
536             pool.run();
537             CPPUNIT_MSG( "   Duration=" << pool.avgDuration() );
538
539             size_t nInsertSuccess = 0;
540             size_t nInsertFailed = 0;
541             size_t nDeleteSuccess = 0;
542             size_t nDeleteFailed = 0;
543             for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) {
544                 insert_thread * pThread = dynamic_cast<insert_thread *>( *it );
545                 if ( pThread ) {
546                     nInsertSuccess += pThread->m_nInsertSuccess;
547                     nInsertFailed += pThread->m_nInsertFailed;
548                 }
549                 else {
550                     delete_thread * p = static_cast<delete_thread *>( *it );
551                     nDeleteSuccess += p->m_nDeleteSuccess;
552                     nDeleteFailed += p->m_nDeleteFailed;
553                 }
554             }
555
556             CPPUNIT_MSG( "  Totals (success/failed): \n\t"
557                 << "      Insert=" << nInsertSuccess << '/' << nInsertFailed << "\n\t"
558                 << "      Delete=" << nDeleteSuccess << '/' << nDeleteFailed << "\n\t"
559                 );
560             CPPUNIT_CHECK( nInsertSuccess == c_nMapSize * c_nInsThreadCount );
561             CPPUNIT_CHECK( nInsertFailed == 0 );
562
563             analyze( testMap );
564         }
565
566         template <class Map>
567         void do_test_extract_with( Map& testMap )
568         {
569             typedef InsertThread<Map> insert_thread;
570             typedef DeleteThread<Map> delete_thread;
571             typedef ExtractThread< typename Map::gc, Map > extract_thread;
572
573             m_nInsThreadCount.store( c_nInsThreadCount, atomics::memory_order_release );
574
575             CppUnitMini::ThreadPool pool( *this );
576             pool.add( new insert_thread( pool, testMap ), c_nInsThreadCount );
577             if ( c_nDelThreadCount )
578                 pool.add( new delete_thread( pool, testMap ), c_nDelThreadCount );
579             if ( c_nExtractThreadCount )
580                 pool.add( new extract_thread( pool, testMap ), c_nExtractThreadCount );
581             pool.run();
582             CPPUNIT_MSG( "   Duration=" << pool.avgDuration() );
583
584             size_t nInsertSuccess = 0;
585             size_t nInsertFailed = 0;
586             size_t nDeleteSuccess = 0;
587             size_t nDeleteFailed = 0;
588             size_t nExtractSuccess = 0;
589             size_t nExtractFailed = 0;
590             for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) {
591                 insert_thread * pThread = dynamic_cast<insert_thread *>( *it );
592                 if ( pThread ) {
593                     nInsertSuccess += pThread->m_nInsertSuccess;
594                     nInsertFailed += pThread->m_nInsertFailed;
595                 }
596                 else {
597                     delete_thread * p = dynamic_cast<delete_thread *>( *it );
598                     if ( p ) {
599                         nDeleteSuccess += p->m_nDeleteSuccess;
600                         nDeleteFailed += p->m_nDeleteFailed;
601                     }
602                     else {
603                         extract_thread * pExtract = dynamic_cast<extract_thread *>( *it );
604                         assert( pExtract );
605                         nExtractSuccess += pExtract->m_nDeleteSuccess;
606                         nExtractFailed += pExtract->m_nDeleteFailed;
607                     }
608                 }
609             }
610
611             CPPUNIT_MSG( "  Totals (success/failed): \n\t"
612                 << "      Insert=" << nInsertSuccess << '/' << nInsertFailed << "\n\t"
613                 << "      Delete=" << nDeleteSuccess << '/' << nDeleteFailed << "\n\t"
614                 << "      Extract=" << nExtractSuccess << '/' << nExtractFailed << "\n\t"
615                 );
616             CPPUNIT_CHECK( nInsertSuccess == c_nMapSize * c_nInsThreadCount );
617             CPPUNIT_CHECK( nInsertFailed == 0 );
618
619             analyze( testMap );
620         }
621
622         template <class Map>
623         void analyze( Map& testMap )
624         {
625             cds::OS::Timer    timer;
626
627             // All even keys must be in the map
628             {
629                 size_t nErrorCount = 0;
630                 CPPUNIT_MSG( "  Check even keys..." );
631                 for ( size_t n = 0; n < c_nMapSize; n +=2 ) {
632                     for ( size_t i = 0; i < c_nInsThreadCount; ++i ) {
633                         if ( !testMap.contains( key_type(n, i) ) ) {
634                             if ( ++nErrorCount < 10 ) {
635                                 CPPUNIT_MSG( "key " << n << "-" << i << " is not found!");
636                             }
637                         }
638                     }
639                 }
640                 CPPUNIT_CHECK_EX( nErrorCount == 0, "Totals: " << nErrorCount << " keys is not found");
641             }
642
643             check_before_cleanup( testMap );
644
645             CPPUNIT_MSG( "  Clear map (single-threaded)..." );
646             timer.reset();
647             testMap.clear();
648             CPPUNIT_MSG( "   Duration=" << timer.duration() );
649             CPPUNIT_CHECK_EX( testMap.empty(), ((long long) testMap.size()) );
650
651             additional_check( testMap );
652             print_stat( testMap );
653
654             additional_cleanup( testMap );
655         }
656
657         //template <class Map>
658         //void test()
659         //{
660         //    CPPUNIT_MSG( "Insert thread count=" << c_nInsThreadCount
661         //        << " delete thread count=" << c_nDelThreadCount
662         //        << " set size=" << c_nMapSize
663         //        );
664
665         //    for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) {
666         //        CPPUNIT_MSG( "Load factor=" << nLoadFactor );
667         //        do_test<Map>( nLoadFactor );
668         //        if ( c_bPrintGCState )
669         //            print_gc_state();
670         //    }
671         //}
672
673         //template <class Map>
674         //void test_extract()
675         //{
676         //    CPPUNIT_MSG( "Thread count: insert=" << c_nInsThreadCount
677         //        << ", delete=" << c_nDelThreadCount
678         //        << ", extract=" << c_nExtractThreadCount
679         //        << "; set size=" << c_nMapSize
680         //        );
681
682         //    for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) {
683         //        CPPUNIT_MSG( "Load factor=" << nLoadFactor );
684         //        do_test_extract<Map>( nLoadFactor );
685         //        if ( c_bPrintGCState )
686         //            print_gc_state();
687         //    }
688         //}
689
690         //template <class Map>
691         //void test_nolf()
692         //{
693         //    CPPUNIT_MSG( "Insert thread count=" << c_nInsThreadCount
694         //        << " delete thread count=" << c_nDelThreadCount
695         //        << " set size=" << c_nMapSize
696         //        );
697
698         //    Map s;
699         //    do_test_with( s );
700         //    if ( c_bPrintGCState )
701         //        print_gc_state();
702         //}
703
704         //template <class Map>
705         //void test_nolf_extract()
706         //{
707         //    CPPUNIT_MSG( "Thread count: insert=" << c_nInsThreadCount
708         //        << ", delete=" << c_nDelThreadCount
709         //        << ", extract=" << c_nExtractThreadCount
710         //        << "; set size=" << c_nMapSize
711         //        );
712
713         //    Map s;
714         //    do_test_extract_with( s );
715         //    if ( c_bPrintGCState )
716         //        print_gc_state();
717         //}
718
719         template <class Map>
720         void run_test()
721         {
722             if ( Map::c_bExtractSupported ) {
723                 CPPUNIT_MSG( "Thread count: insert=" << c_nInsThreadCount
724                     << ", delete=" << c_nDelThreadCount
725                     << ", extract=" << c_nExtractThreadCount
726                     << "; set size=" << c_nMapSize
727                     );
728                 if ( Map::c_bLoadFactorDepended ) {
729                     for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
730                         CPPUNIT_MSG( "Load factor=" << c_nLoadFactor );
731                         do_test_extract<Map>();
732                         if ( c_bPrintGCState )
733                             print_gc_state();
734                     }
735                 }
736                 else
737                     do_test_extract<Map>();
738             }
739             else {
740                 CPPUNIT_MSG( "Insert thread count=" << c_nInsThreadCount
741                     << " delete thread count=" << c_nDelThreadCount
742                     << " set size=" << c_nMapSize
743                     );
744                 if ( Map::c_bLoadFactorDepended ) {
745                     for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
746                         CPPUNIT_MSG( "Load factor=" << c_nLoadFactor );
747                         do_test<Map>();
748                         if ( c_bPrintGCState )
749                             print_gc_state();
750                     }
751                 }
752                 else
753                     do_test<Map>();
754             }
755         }
756
757         void setUpParams( const CppUnitMini::TestCfg& cfg );
758
759         //void run_MichaelMap(const char *in_name, bool invert = false);
760         //void run_SplitList(const char *in_name, bool invert = false);
761         ////void run_StripedMap(const char *in_name, bool invert = false);
762         ////void run_RefinableMap(const char *in_name, bool invert = false);
763         //void run_CuckooMap(const char *in_name, bool invert = false);
764         //void run_SkipListMap(const char *in_name, bool invert = false);
765         //void run_EllenBinTreeMap(const char *in_name, bool invert = false);
766         //void run_BronsonAVLTreeMap(const char *in_name, bool invert = false);
767         //void run_MultiLevelHashMap(const char *in_name, bool invert = false);
768         ////void run_StdMap(const char *in_name, bool invert = false);
769
770         //virtual void myRun(const char *in_name, bool invert = false);
771
772 #   include "map2/map_defs.h"
773         CDSUNIT_DECLARE_MichaelMap
774         CDSUNIT_DECLARE_MultiLevelHashMap
775
776         CPPUNIT_TEST_SUITE(Map_DelOdd)
777             CDSUNIT_TEST_MichaelMap
778             //CDSUNIT_TEST_MultiLevelHashMap
779         CPPUNIT_TEST_SUITE_END();
780
781         //CDSUNIT_DECLARE_MichaelMap
782         //CDSUNIT_DECLARE_SplitList
783         ////CDSUNIT_DECLARE_StripedMap
784         ////CDSUNIT_DECLARE_RefinableMap
785         //CDSUNIT_DECLARE_CuckooMap
786         //CDSUNIT_DECLARE_SkipListMap
787         //CDSUNIT_DECLARE_EllenBinTreeMap
788         //CDSUNIT_DECLARE_BronsonAVLTreeMap
789         //CDSUNIT_DECLARE_MultiLevelHashMap
790         ////CDSUNIT_DECLARE_StdMap
791     };
792 } // namespace map2