persistent-cache-cpp
|
Class that provides (read-only) access to cache statistics and settings. More...
#include <core/persistent_cache_stats.h>
Public Member Functions | |
Construction, Copy and Assignment | |
Copy and assignment have the usual value semantics. The default constructor creates an instance with an empty cache path, | |
PersistentCacheStats () | |
PersistentCacheStats (PersistentCacheStats const &) | |
PersistentCacheStats (PersistentCacheStats &&) noexcept | |
PersistentCacheStats & | operator= (PersistentCacheStats const &) |
PersistentCacheStats & | operator= (PersistentCacheStats &&) |
Accessors | |
typedef std::vector< uint32_t > | Histogram |
Histogram of the size distribution of cache entries. | |
typedef std::vector< std::pair< int32_t, int32_t > > | HistogramBounds |
Lower and upper bounds for the bins in the histogram. | |
static constexpr unsigned | NUM_BINS = 74 |
The number of bins in a histogram. | |
std::string | cache_path () const |
Returns the path to the cache directory. | |
CacheDiscardPolicy | policy () const noexcept |
Returns the discard policy (lru_only or lru_ttl ). | |
int64_t | size () const noexcept |
Returns the number of entries (including expired ones). | |
int64_t | size_in_bytes () const noexcept |
Returns the size of all entries (including expired ones). | |
int64_t | max_size_in_bytes () const noexcept |
Returns the maximum size of the cache. | |
int64_t | hits () const noexcept |
Returns the number of hits since the statistics were last reset. | |
int64_t | misses () const noexcept |
Returns the number of misses since the statistics were last reset. | |
int64_t | hits_since_last_miss () const noexcept |
Returns the number of consecutive hits since the last miss. | |
int64_t | misses_since_last_hit () const noexcept |
Returns the number of consecutive misses since the last hit. | |
int64_t | longest_hit_run () const noexcept |
Returns the largest number of consecutive hits. | |
int64_t | longest_miss_run () const noexcept |
Returns the largest number of consecutive misses. | |
int64_t | hit_runs () const noexcept |
Returns the number of hit runs. | |
int64_t | miss_runs () const noexcept |
Returns the number of miss runs. | |
double | avg_hit_run_length () const noexcept |
Returns a rolling average of the hit run length. | |
double | avg_miss_run_length () const noexcept |
Returns a rolling average of the miss run length. | |
int64_t | ttl_evictions () const noexcept |
Returns the number of entries that were evicted due to being expired. | |
int64_t | lru_evictions () const noexcept |
Returns the number of entries that were evicted due to being least recently used. | |
std::chrono::system_clock::time_point | most_recent_hit_time () const noexcept |
Returns the timestamp of the most recent hit. | |
std::chrono::system_clock::time_point | most_recent_miss_time () const noexcept |
Returns the timestamp of the most recent miss. | |
std::chrono::system_clock::time_point | longest_hit_run_time () const noexcept |
Returns the time of the longest hit run. | |
std::chrono::system_clock::time_point | longest_miss_run_time () const noexcept |
Returns the time of the longest miss run. | |
Histogram const & | histogram () const noexcept |
Returns a histogram for the entries in the cache. | |
static HistogramBounds const & | histogram_bounds () noexcept |
Returns the bounds for each bin a histogram. | |
Class that provides (read-only) access to cache statistics and settings.
typedef std::vector<uint32_t> core::PersistentCacheStats::Histogram |
Histogram of the size distribution of cache entries.
The histogram uses a logarithmic scale and contains the number of entries in the cache, with entries grouped by size into a number of bins as follows:
Index | Entry size in bytes |
---|---|
0 | 1..9 |
1 | 10..19 |
2 | 20..29 |
... | ... |
9 | 90..99 |
10 | 100..199 |
11 | 200..200 |
... | ... |
18 | 900..999 |
19 | 1,000..1,999 |
20 | 2,000..2,999 |
... | ... |
27 | 9,000..9,999 |
28 | 10,000..19,999 |
29 | 20,000..29,999 |
... | ... |
72 | 900,000,000..999,999,999 |
73 | 1,000,000,000.. |
Index 0 contains the number of entries < 10 bytes. Thereafter, the histogram contains 9 bins for each power of 10, plus a final bin at index 73 that contains the number of entries ≥ 109 bytes.
typedef std::vector<std::pair<int32_t, int32_t> > core::PersistentCacheStats::HistogramBounds |
Lower and upper bounds for the bins in the histogram.
Each pair contains the lower and upper (inclusive) bound of the corresponding bin of the values returned by histogram().
core::PersistentCacheStats::PersistentCacheStats | ( | ) |
core::PersistentCacheStats::PersistentCacheStats | ( | PersistentCacheStats const & | ) |
|
noexcept |
|
noexcept |
Returns a rolling average of the hit run length.
|
noexcept |
Returns a rolling average of the miss run length.
std::string core::PersistentCacheStats::cache_path | ( | ) | const |
Returns the path to the cache directory.
|
noexcept |
Returns a histogram for the entries in the cache.
|
staticnoexcept |
Returns the bounds for each bin a histogram.
This method returns the same vector each time; it is provided as a convenience method to make it easier to add labels to a histogram for display. The returned pairs use inclusive ranges, that is, pair.second
is the largest possible size of the bin.
|
noexcept |
Returns the number of hit runs.
|
noexcept |
Returns the number of hits since the statistics were last reset.
|
noexcept |
Returns the number of consecutive hits since the last miss.
|
noexcept |
Returns the largest number of consecutive hits.
|
noexcept |
Returns the time of the longest hit run.
|
noexcept |
Returns the largest number of consecutive misses.
|
noexcept |
Returns the time of the longest miss run.
|
noexcept |
Returns the number of entries that were evicted due to being least recently used.
|
noexcept |
Returns the maximum size of the cache.
|
noexcept |
Returns the number of miss runs.
|
noexcept |
Returns the number of misses since the statistics were last reset.
|
noexcept |
Returns the number of consecutive misses since the last hit.
|
noexcept |
Returns the timestamp of the most recent hit.
|
noexcept |
Returns the timestamp of the most recent miss.
PersistentCacheStats & core::PersistentCacheStats::operator= | ( | PersistentCacheStats && | ) |
PersistentCacheStats & core::PersistentCacheStats::operator= | ( | PersistentCacheStats const & | ) |
|
noexcept |
Returns the discard policy (lru_only
or lru_ttl
).
|
noexcept |
Returns the number of entries (including expired ones).
|
noexcept |
Returns the size of all entries (including expired ones).
|
noexcept |
Returns the number of entries that were evicted due to being expired.
|
staticconstexpr |
The number of bins in a histogram.