From 93ea1ee748286601ada2e46a5afaf9e5e3fba319 Mon Sep 17 00:00:00 2001 From: khizmax Date: Wed, 9 Dec 2015 22:42:05 +0300 Subject: [PATCH] Tune FeldmanHashMap tests --- tests/unit/map2/map_delodd.h | 4 ++-- tests/unit/map2/map_delodd_feldmanhashmap.cpp | 2 +- tests/unit/map2/map_insdel_func.h | 7 +++++-- tests/unit/map2/map_type_feldman_hashmap.h | 3 +++ tests/unit/print_feldman_hashset_stat.h | 17 +++++++++++++++++ tests/unit/set2/set_type_feldman_hashset.h | 4 ++++ 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/tests/unit/map2/map_delodd.h b/tests/unit/map2/map_delodd.h index 883d6f8c..10009ae8 100644 --- a/tests/unit/map2/map_delodd.h +++ b/tests/unit/map2/map_delodd.h @@ -777,7 +777,7 @@ namespace map2 { CDSUNIT_DECLARE_EllenBinTreeMap CDSUNIT_DECLARE_BronsonAVLTreeMap CDSUNIT_DECLARE_FeldmanHashMap_fixed - CDSUNIT_DECLARE_FeldmanHashMap_city + //CDSUNIT_DECLARE_FeldmanHashMap_city CDSUNIT_DECLARE_CuckooMap CPPUNIT_TEST_SUITE(Map_DelOdd) @@ -787,7 +787,7 @@ namespace map2 { CDSUNIT_TEST_EllenBinTreeMap CDSUNIT_TEST_BronsonAVLTreeMap CDSUNIT_TEST_FeldmanHashMap_fixed - CDSUNIT_TEST_FeldmanHashMap_city + //CDSUNIT_TEST_FeldmanHashMap_city CDSUNIT_TEST_CuckooMap CPPUNIT_TEST_SUITE_END(); diff --git a/tests/unit/map2/map_delodd_feldmanhashmap.cpp b/tests/unit/map2/map_delodd_feldmanhashmap.cpp index 11c4d749..aa6e8418 100644 --- a/tests/unit/map2/map_delodd_feldmanhashmap.cpp +++ b/tests/unit/map2/map_delodd_feldmanhashmap.cpp @@ -9,5 +9,5 @@ namespace map2 { CDSUNIT_DECLARE_FeldmanHashMap_fixed - CDSUNIT_DECLARE_FeldmanHashMap_city + //CDSUNIT_DECLARE_FeldmanHashMap_city } // namespace map2 diff --git a/tests/unit/map2/map_insdel_func.h b/tests/unit/map2/map_insdel_func.h index 83d64b24..ded6542e 100644 --- a/tests/unit/map2/map_insdel_func.h +++ b/tests/unit/map2/map_insdel_func.h @@ -219,8 +219,11 @@ namespace map2 { template void operator()( Val& cur, Val * old ) { - if ( old ) + if ( old ) { + cur.second.nKey = cur.first; + cur.second.nData = cur.first * 8; cur.second.bInitialized.store( true, atomics::memory_order_release ); + } operator()( old == nullptr, cur.first, cur.second ); } @@ -334,7 +337,7 @@ namespace map2 { { while ( true ) { if ( v.bInitialized.load( atomics::memory_order_relaxed )) { - std::unique_lock< typename value_type::lock_type> ac( v.m_access ); + std::unique_lock< typename value_type::lock_type> ac( v.m_access ); if ( m_cnt.nKeyExpected == v.nKey && m_cnt.nKeyExpected * 8 == v.nData ) ++m_cnt.nSuccessItem; diff --git a/tests/unit/map2/map_type_feldman_hashmap.h b/tests/unit/map2/map_type_feldman_hashmap.h index 6d6dd475..0896230c 100644 --- a/tests/unit/map2/map_type_feldman_hashmap.h +++ b/tests/unit/map2/map_type_feldman_hashmap.h @@ -165,6 +165,8 @@ namespace map2 { std::vector< cds::intrusive::feldman_hashset::level_statistics > level_stat; m.get_level_statistics( level_stat ); + CPPUNIT_MSG( level_stat ); + /* CPPUNIT_MSG( "Level statistics, height=" << level_stat.size()); size_t i = 0; CPPUNIT_MSG( " i node_count capacity data_cell array_cell empty_cell" ); @@ -177,6 +179,7 @@ namespace map2 { << std::setw(12) << it->empty_cell_count << std::setw(0) ); } + */ } } // namespace map2 diff --git a/tests/unit/print_feldman_hashset_stat.h b/tests/unit/print_feldman_hashset_stat.h index 73560dec..142b8ad1 100644 --- a/tests/unit/print_feldman_hashset_stat.h +++ b/tests/unit/print_feldman_hashset_stat.h @@ -37,6 +37,23 @@ namespace std { return o; } + static inline ostream& operator<<( ostream& o, std::vector< cds::intrusive::feldman_hashset::level_statistics > const& level_stat ) + { + o << "Level statistics, height=" << level_stat.size() << "\n"; + size_t i = 0; + o << " i node_count capacity data_cell array_cell empty_cell\n"; + for ( auto it = level_stat.begin(); it != level_stat.end(); ++it, ++i ) { + o << std::setw( 3 ) << i << std::setw( 0 ) << " " + << std::setw( 12 ) << it->array_node_count << std::setw( 0 ) << " " + << std::setw( 8 ) << it->node_capacity << std::setw( 0 ) << " " + << std::setw( 12 ) << it->data_cell_count << std::setw( 0 ) << " " + << std::setw( 12 ) << it->array_cell_count << std::setw( 0 ) << " " + << std::setw( 12 ) << it->empty_cell_count << std::setw( 0 ) + << "\n"; + } + return o; + } + } // namespace std #endif // #ifndef CDSUNIT_PRINT_FELDMAN_HASHSET_STAT_H diff --git a/tests/unit/set2/set_type_feldman_hashset.h b/tests/unit/set2/set_type_feldman_hashset.h index 2b2b9d57..f9f00992 100644 --- a/tests/unit/set2/set_type_feldman_hashset.h +++ b/tests/unit/set2/set_type_feldman_hashset.h @@ -284,6 +284,10 @@ namespace set2 { static inline void print_stat( FeldmanHashSet< GC, T, Traits > const& s ) { CPPUNIT_MSG( s.statistics() ); + + std::vector< cds::intrusive::feldman_hashset::level_statistics > level_stat; + s.get_level_statistics( level_stat ); + CPPUNIT_MSG( level_stat ); } } // namespace set2 -- 2.34.1