mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
added stats to foa::concurrent_table
This commit is contained in:
@ -469,6 +469,10 @@ public:
|
||||
using size_type=typename super::size_type;
|
||||
static constexpr std::size_t bulk_visit_size=16;
|
||||
|
||||
#if defined(BOOST_UNORDERED_ENABLE_STATS)
|
||||
using stats=typename super::stats;
|
||||
#endif
|
||||
|
||||
private:
|
||||
template<typename Value,typename T>
|
||||
using enable_if_is_value_type=typename std::enable_if<
|
||||
@ -965,6 +969,13 @@ public:
|
||||
super::reserve(n);
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_ENABLE_STATS)
|
||||
/* already thread safe */
|
||||
|
||||
using super::get_stats;
|
||||
using super::reset_stats;
|
||||
#endif
|
||||
|
||||
template<typename Predicate>
|
||||
friend std::size_t erase_if(concurrent_table& x,Predicate&& pr)
|
||||
{
|
||||
@ -1186,6 +1197,7 @@ private:
|
||||
GroupAccessMode access_mode,
|
||||
const Key& x,std::size_t pos0,std::size_t hash,F&& f)const
|
||||
{
|
||||
BOOST_UNORDERED_STATS_COUNTER(num_cmps);
|
||||
prober pb(pos0);
|
||||
do{
|
||||
auto pos=pb.get();
|
||||
@ -1197,19 +1209,30 @@ private:
|
||||
auto lck=access(access_mode,pos);
|
||||
do{
|
||||
auto n=unchecked_countr_zero(mask);
|
||||
if(BOOST_LIKELY(
|
||||
pg->is_occupied(n)&&bool(this->pred()(x,this->key_from(p[n]))))){
|
||||
f(pg,n,p+n);
|
||||
return 1;
|
||||
if(BOOST_LIKELY(pg->is_occupied(n))){
|
||||
BOOST_UNORDERED_INCREMENT_STATS_COUNTER(num_cmps);
|
||||
if(BOOST_LIKELY(bool(this->pred()(x,this->key_from(p[n]))))){
|
||||
f(pg,n,p+n);
|
||||
BOOST_UNORDERED_ADD_STATS(
|
||||
this->successful_lookup_cumulative_stats(),
|
||||
(pb.length(),num_cmps));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
mask&=mask-1;
|
||||
}while(mask);
|
||||
}
|
||||
if(BOOST_LIKELY(pg->is_not_overflowed(hash))){
|
||||
BOOST_UNORDERED_ADD_STATS(
|
||||
this->unsuccessful_lookup_cumulative_stats(),
|
||||
(pb.length(),num_cmps));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while(BOOST_LIKELY(pb.next(this->arrays.groups_size_mask)));
|
||||
BOOST_UNORDERED_ADD_STATS(
|
||||
this->unsuccessful_lookup_cumulative_stats(),
|
||||
(pb.length(),num_cmps));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1490,6 +1513,8 @@ private:
|
||||
this->construct_element(p,std::forward<Args>(args)...);
|
||||
rslot.commit();
|
||||
rsize.commit();
|
||||
BOOST_UNORDERED_ADD_STATS(
|
||||
this->insertion_cumulative_stats(),(pb.length()));
|
||||
return 1;
|
||||
}
|
||||
pg->mark_overflow(hash);
|
||||
|
@ -1435,6 +1435,9 @@ public:
|
||||
|
||||
#if defined(BOOST_UNORDERED_ENABLE_STATS)
|
||||
using stats=table_core_stats;
|
||||
using cumulative_insertion_stats=concurrent_cumulative_stats<1>;
|
||||
using cumulative_successful_lookup_stats=concurrent_cumulative_stats<2>;
|
||||
using cumulative_unsuccessful_lookup_stats=concurrent_cumulative_stats<2>;
|
||||
#endif
|
||||
|
||||
table_core(
|
||||
@ -1814,6 +1817,23 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
cumulative_insertion_stats& insertion_cumulative_stats()noexcept
|
||||
{
|
||||
return insertion_stats;
|
||||
}
|
||||
|
||||
cumulative_successful_lookup_stats&
|
||||
successful_lookup_cumulative_stats()const noexcept
|
||||
{
|
||||
return successful_lookup_stats;
|
||||
}
|
||||
|
||||
cumulative_unsuccessful_lookup_stats&
|
||||
unsuccessful_lookup_cumulative_stats()const noexcept
|
||||
{
|
||||
return unsuccessful_lookup_stats;
|
||||
}
|
||||
|
||||
void reset_stats()
|
||||
{
|
||||
insertion_stats.reset();
|
||||
@ -2033,9 +2053,9 @@ public:
|
||||
size_ctrl_type size_ctrl;
|
||||
|
||||
#if defined(BOOST_UNORDERED_ENABLE_STATS)
|
||||
concurrent_cumulative_stats<1> insertion_stats;
|
||||
mutable concurrent_cumulative_stats<2> successful_lookup_stats,
|
||||
unsuccessful_lookup_stats;
|
||||
cumulative_insertion_stats insertion_stats;
|
||||
mutable cumulative_successful_lookup_stats successful_lookup_stats;
|
||||
mutable cumulative_unsuccessful_lookup_stats unsuccessful_lookup_stats;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user