From: Marcin Siodelski Date: Thu, 12 Jul 2012 14:49:10 +0000 (+0200) Subject: [1958] Added custom transaction id hashing in perfdhcp stats manager. X-Git-Tag: trac2351_base~113^2~20^2~1^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df4d0be872ff9ff4e120e156b71d0abc25df0319;p=thirdparty%2Fkea.git [1958] Added custom transaction id hashing in perfdhcp stats manager. --- diff --git a/tests/tools/perfdhcp/stats_mgr.h b/tests/tools/perfdhcp/stats_mgr.h index 507e6fd11f..b224fa7d8b 100644 --- a/tests/tools/perfdhcp/stats_mgr.h +++ b/tests/tools/perfdhcp/stats_mgr.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -70,6 +70,10 @@ public: class ExchangeStats { public: + static uint32_t transid_hash(boost::shared_ptr packet) { + return packet->getTransid() & 1023; + } + /// \brief List of packets (sent or received). /// /// List of packets based on multi index container allows efficient @@ -80,8 +84,8 @@ public: boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_non_unique< - boost::multi_index::const_mem_fun< - T, uint32_t, &T::getTransid + boost::multi_index::global_fun< + boost::shared_ptr, uint32_t, &ExchangeStats::transid_hash > > > @@ -158,7 +162,7 @@ public: } else { PktListTransidIndex& idx = sent_packets_.template get<1>(); std::pair p = - idx.equal_range(transid); + idx.equal_range(transid & 1023); ++unordered_lookups_; unordered_lookup_size_sum_ += std::distance(p.first, p.second); for (PktListTransidIterator it = p.first; it != p.second; diff --git a/tests/tools/perfdhcp/tests/stats_mgr_unittest.cc b/tests/tools/perfdhcp/tests/stats_mgr_unittest.cc index 8d6ee8398a..2d6ab14d54 100644 --- a/tests/tools/perfdhcp/tests/stats_mgr_unittest.cc +++ b/tests/tools/perfdhcp/tests/stats_mgr_unittest.cc @@ -108,9 +108,8 @@ TEST_F(StatsMgrTest, SendReceiveUnordered) { boost::scoped_ptr stats_mgr(new StatsMgr4()); stats_mgr->addExchangeStats(StatsMgr4::XCHG_DO); - uint32_t transid[packets_num] = { 64322, 100203, 1, 232324, 6786, 23, 4523, 777883, 98082, 3 }; + uint32_t transid[packets_num] = { 1, 1024, 2, 1025, 3, 1026, 4, 1027, 5, 1028 }; for (int i = 0; i < packets_num; ++i) { - // uint32_t transid = i & 0xFFFFFFFE | !(i & 1); boost::shared_ptr sent_packet(createPacket4(DHCPDISCOVER, transid[i])); ASSERT_NO_THROW(