Stat to measure freq of elements with a name and a description.
More...
#include <stats.hh>
|
| StatsFreq (bool reg=true) |
|
void | init (const std::string &name, const std::string &desc, size_t bucket_cnt, T bucket_min, T bucket_max) |
| Initialize the stats' buckets. More...
|
|
void | add (T val, size_t count=1) |
| Add a value to the frequency map. More...
|
|
size_t | total () const |
| Get the total number of samples. More...
|
|
size_t | bucket_count (size_t bucket) const |
| Get the number of samples in a bucket. More...
|
|
size_t | uoflow_count (bool underflow_cnt, bool overflow_cnt) const |
| Get the number of samples in overflow and underflow buckets. More...
|
|
std::string | str () const |
| Generate a string representation of the frequency map.
|
|
| StatsBase (bool reg) |
|
void | init (const std::string &name, const std::string &desc) |
|
virtual double | avg () const |
|
virtual std::string | latex (const std::string &prefix="") const |
|
| StatsBase (bool reg) |
|
void | init (const std::string &name, const std::string &desc) |
|
virtual double | avg () const |
|
virtual std::string | latex (const std::string &prefix="") const |
|
|
size_t | bucket_cnt |
|
T | bucket_min |
|
T | bucket_max |
|
T | bucket_sz |
|
size_t * | counts |
|
size_t | underflow_cnt |
|
size_t | overflow_cnt |
|
|
std::string | stat_name |
|
std::string | stat_desc |
|
template<typename T = size_t>
class nvsl::StatsFreq< T >
Stat to measure freq of elements with a name and a description.
Definition at line 74 of file stats.hh.
◆ add()
template<typename T = size_t>
Add a value to the frequency map.
- Parameters
-
[in] | val | Value to sample |
[in] | count=1 | Number of times to add this value to the map |
Definition at line 126 of file stats.hh.
127 if (val < bucket_min) {
129 }
else if (val >= bucket_max) {
132 size_t bucket_idx = (val-bucket_min)/bucket_sz;
133 counts[bucket_idx]++;
◆ bucket_count()
template<typename T = size_t>
Get the number of samples in a bucket.
- Parameters
-
- Returns
- Number of samples in the bucket
Definition at line 151 of file stats.hh.
152 return counts[bucket];
◆ init()
template<typename T = size_t>
void nvsl::StatsFreq< T >::init |
( |
const std::string & |
name, |
|
|
const std::string & |
desc, |
|
|
size_t |
bucket_cnt, |
|
|
T |
bucket_min, |
|
|
T |
bucket_max |
|
) |
| |
|
inline |
Initialize the stats' buckets.
- Parameters
-
name | Name of the stat |
desc | Description of the stat |
bucket_cnt | Number of buckets |
bucket_min | Minimum value of the bucket |
bucket_max | Maximum value of the bucket |
bucket_sz | Size of the bucket |
Definition at line 96 of file stats.hh.
99 NVSL_ASSERT(bucket_cnt != 0,
"Bucket size cannot be zero");
101 "Bucket max cannot be smaller than bucket min");
103 assert(bucket_cnt != 0 &&
"Bucket size cannot be zero");
104 assert(bucket_max > bucket_min &&
105 "Bucket max cannot be smaller than bucket min");
108 StatsBase::init(name, desc);
110 this->bucket_cnt = bucket_cnt;
111 this->bucket_min = bucket_min;
112 this->bucket_max = bucket_max;
113 this->bucket_sz = (bucket_max-bucket_min)/bucket_cnt;
114 this->underflow_cnt = 0;
115 this->overflow_cnt = 0;
117 this->counts =
new size_t[bucket_cnt];
118 memset(counts, 0,
sizeof(counts[0])*bucket_cnt);
◆ total()
template<typename T = size_t>
Get the total number of samples.
- Returns
- Total number of samples
Definition at line 141 of file stats.hh.
142 return underflow_cnt + overflow_cnt +
143 std::accumulate(counts, counts+bucket_cnt, 0);
◆ uoflow_count()
template<typename T = size_t>
size_t nvsl::StatsFreq< T >::uoflow_count |
( |
bool |
underflow_cnt, |
|
|
bool |
overflow_cnt |
|
) |
| const |
|
inline |
Get the number of samples in overflow and underflow buckets.
- Parameters
-
[in] | underflow_cnt | Return the number of samples in underflow bucket |
[in] | overflow_cnt | Return the number of samples in overflow bucket |
- Returns
- Number of samples in overflow and underflow buckets (whichever is enabled)
Definition at line 161 of file stats.hh.
162 return (underflow_cnt ? this->underflow_cnt : 0) +
163 (overflow_cnt ? this->overflow_cnt : 0);
The documentation for this class was generated from the following file: