From: Marcin Siodelski Date: Mon, 23 Jul 2012 14:22:42 +0000 (+0200) Subject: [1958] Use hashing function for indexing and unordered search. X-Git-Tag: trac2351_base~113^2~20^2~1^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98c3fe102ae4b4e8769d2bf9412a5e5ab9225926;p=thirdparty%2Fkea.git [1958] Use hashing function for indexing and unordered search. --- diff --git a/tests/tools/perfdhcp/stats_mgr.h b/tests/tools/perfdhcp/stats_mgr.h index cae102930b..7732bce8eb 100644 --- a/tests/tools/perfdhcp/stats_mgr.h +++ b/tests/tools/perfdhcp/stats_mgr.h @@ -131,7 +131,7 @@ public: class ExchangeStats { public: - static uint32_t transid_hash(const boost::shared_ptr packet) { + static uint32_t hashTransid(const boost::shared_ptr packet) { return packet->getTransid() & 1023; } @@ -148,7 +148,7 @@ public: boost::multi_index::global_fun< boost::shared_ptr, uint32_t, - &ExchangeStats::transid_hash + &ExchangeStats::hashTransid > > > @@ -259,7 +259,7 @@ public: /// \param transid transaction id of the packet to search /// \return packet having specified transaction or NULL if packet /// not found - boost::shared_ptr findSent(const uint32_t transid) { + boost::shared_ptr findSent(const boost::shared_ptr rcvd_packet) { if (sent_packets_.size() == 0) { // List of sent packets is empty so there is no sense // to continue looking fo the packet. It also means @@ -283,7 +283,7 @@ public: // incoming packet. We are successful if there is no // packet drop or out of order packets sent. This is actually // the fastest way to look for packets. - if ((*sent_packets_cache_)->getTransid() == transid) { + if ((*sent_packets_cache_)->getTransid() == rcvd_packet->getTransid()) { ++ordered_lookups_; packet_found = true; } else { @@ -299,7 +299,7 @@ public: // bucket of packets and we need to iterate through the bucket // to find the one that has desired transaction id. std::pair p = - idx.equal_range(transid & 1023); + idx.equal_range(hashTransid(rcvd_packet)); // We want to keep statistics of unordered lookups to make // sure that there is a right balance between number of // unordered lookups and ordered lookups. If number of unordered @@ -312,7 +312,7 @@ public: unordered_lookup_size_sum_ += std::distance(p.first, p.second); for (PktListTransidIterator it = p.first; it != p.second; ++it) { - if ((*it)->getTransid() == transid) { + if ((*it)->getTransid() == rcvd_packet->getTransid()) { packet_found = true; sent_packets_cache_ = sent_packets_.template project<0>(it); @@ -592,7 +592,7 @@ public: const boost::shared_ptr packet) { ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type); boost::shared_ptr sent_packet - = xchg_stats->findSent(packet->getTransid()); + = xchg_stats->findSent(packet); if (sent_packet) { xchg_stats->updateDelays(sent_packet, packet);