mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
added stats to bulk visitation
This commit is contained in:
@ -1265,6 +1265,7 @@ private:
|
|||||||
|
|
||||||
it=first;
|
it=first;
|
||||||
for(auto i=m;i--;++it){
|
for(auto i=m;i--;++it){
|
||||||
|
BOOST_UNORDERED_STATS_COUNTER(num_cmps);
|
||||||
auto pos=positions[i];
|
auto pos=positions[i];
|
||||||
prober pb(pos);
|
prober pb(pos);
|
||||||
auto pg=this->arrays.groups()+pos;
|
auto pg=this->arrays.groups()+pos;
|
||||||
@ -1277,12 +1278,15 @@ private:
|
|||||||
auto lck=access(access_mode,pos);
|
auto lck=access(access_mode,pos);
|
||||||
do{
|
do{
|
||||||
auto n=unchecked_countr_zero(mask);
|
auto n=unchecked_countr_zero(mask);
|
||||||
if(BOOST_LIKELY(
|
if(BOOST_LIKELY(pg->is_occupied(n))){
|
||||||
pg->is_occupied(n)&&
|
BOOST_UNORDERED_INCREMENT_STATS_COUNTER(num_cmps);
|
||||||
bool(this->pred()(*it,this->key_from(p[n]))))){
|
if(bool(this->pred()(*it,this->key_from(p[n])))){
|
||||||
f(cast_for(access_mode,type_policy::value_from(p[n])));
|
f(cast_for(access_mode,type_policy::value_from(p[n])));
|
||||||
++res;
|
++res;
|
||||||
goto next_key;
|
BOOST_UNORDERED_ADD_STATS(
|
||||||
|
this->cstats.successful_lookup,(pb.length(),num_cmps));
|
||||||
|
goto next_key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mask&=mask-1;
|
mask&=mask-1;
|
||||||
}while(mask);
|
}while(mask);
|
||||||
@ -1291,6 +1295,8 @@ private:
|
|||||||
do{
|
do{
|
||||||
if(BOOST_LIKELY(pg->is_not_overflowed(hashes[i]))||
|
if(BOOST_LIKELY(pg->is_not_overflowed(hashes[i]))||
|
||||||
BOOST_UNLIKELY(!pb.next(this->arrays.groups_size_mask))){
|
BOOST_UNLIKELY(!pb.next(this->arrays.groups_size_mask))){
|
||||||
|
BOOST_UNORDERED_ADD_STATS(
|
||||||
|
this->cstats.unsuccessful_lookup,(pb.length(),num_cmps));
|
||||||
goto next_key;
|
goto next_key;
|
||||||
}
|
}
|
||||||
pos=pb.get();
|
pos=pb.get();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "../helpers/random_values.hpp"
|
#include "../helpers/random_values.hpp"
|
||||||
#include "../helpers/test.hpp"
|
#include "../helpers/test.hpp"
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
#include <boost/core/make_span.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
template <class T> struct unequal_allocator
|
template <class T> struct unequal_allocator
|
||||||
@ -215,16 +216,29 @@ template <class Container> void test_stats()
|
|||||||
|
|
||||||
#if defined(BOOST_UNORDERED_CFOA_TESTS)
|
#if defined(BOOST_UNORDERED_CFOA_TESTS)
|
||||||
|
|
||||||
|
using key_type = typename Container::key_type;
|
||||||
using value_type = typename Container::value_type;
|
using value_type = typename Container::value_type;
|
||||||
|
|
||||||
test::random_values<Container> l2(15000, test::sequential);
|
test::random_values<Container> l2(15000, test::sequential);
|
||||||
std::vector<value_type> v2(l2.begin(), l2.end());
|
std::vector<value_type> v2(l2.begin(), l2.end());
|
||||||
std::atomic<int> found{0}, not_found{0};
|
std::atomic<int> found{0}, not_found{0};
|
||||||
thread_runner(v2, [&cc, &found, ¬_found](boost::span<value_type> sp) {
|
thread_runner(v2, [&cc, &found, ¬_found](boost::span<value_type> sp) {
|
||||||
for (auto const& x : sp) {
|
// Half the span looked up elementwise
|
||||||
|
auto sp1 = boost::make_span(sp.begin(), sp.size()/2);
|
||||||
|
for (auto const& x : sp1) {
|
||||||
if(cc.contains(test::get_key<Container>(x))) ++found;
|
if(cc.contains(test::get_key<Container>(x))) ++found;
|
||||||
else ++not_found;
|
else ++not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Second half looked up in bulk
|
||||||
|
std::vector<key_type> ksp2;
|
||||||
|
for (auto const& x : boost::make_span(sp1.end(), sp.end())) {
|
||||||
|
ksp2.push_back(test::get_key<Container>(x));
|
||||||
|
}
|
||||||
|
auto visited = cc.visit(
|
||||||
|
ksp2.begin(), ksp2.end(), [](const value_type&) {});
|
||||||
|
found += visited;
|
||||||
|
not_found += ksp2.size() - visited;
|
||||||
});
|
});
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user