Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::memory_pool_statistics Struct Reference

Statistics for memory pool operations. More...

#include <memory_pool.h>

Collaboration diagram for kcenon::monitoring::memory_pool_statistics:
Collaboration graph

Public Member Functions

 memory_pool_statistics ()=default
 
 memory_pool_statistics (const memory_pool_statistics &other)
 
memory_pool_statisticsoperator= (const memory_pool_statistics &other)
 
 memory_pool_statistics (memory_pool_statistics &&other) noexcept
 
memory_pool_statisticsoperator= (memory_pool_statistics &&other) noexcept
 
double get_allocation_success_rate () const
 Get allocation success rate.
 
void reset ()
 Reset all statistics.
 

Public Attributes

std::atomic< size_t > total_allocations {0}
 
std::atomic< size_t > total_deallocations {0}
 
std::atomic< size_t > allocation_failures {0}
 
std::atomic< size_t > peak_usage {0}
 

Detailed Description

Statistics for memory pool operations.

Definition at line 103 of file memory_pool.h.

Constructor & Destructor Documentation

◆ memory_pool_statistics() [1/3]

kcenon::monitoring::memory_pool_statistics::memory_pool_statistics ( )
default

◆ memory_pool_statistics() [2/3]

kcenon::monitoring::memory_pool_statistics::memory_pool_statistics ( const memory_pool_statistics & other)
inline

Definition at line 110 of file memory_pool.h.

111 : total_allocations(other.total_allocations.load())
112 , total_deallocations(other.total_deallocations.load())
113 , allocation_failures(other.allocation_failures.load())
114 , peak_usage(other.peak_usage.load()) {}

◆ memory_pool_statistics() [3/3]

kcenon::monitoring::memory_pool_statistics::memory_pool_statistics ( memory_pool_statistics && other)
inlinenoexcept

Definition at line 126 of file memory_pool.h.

127 : total_allocations(other.total_allocations.load())
128 , total_deallocations(other.total_deallocations.load())
129 , allocation_failures(other.allocation_failures.load())
130 , peak_usage(other.peak_usage.load()) {}

Member Function Documentation

◆ get_allocation_success_rate()

double kcenon::monitoring::memory_pool_statistics::get_allocation_success_rate ( ) const
inline

Get allocation success rate.

Returns
Success rate between 0.0 and 100.0

Definition at line 146 of file memory_pool.h.

146 {
147 auto total = total_allocations.load() + allocation_failures.load();
148 if (total == 0) {
149 return 100.0;
150 }
151 return (static_cast<double>(total_allocations.load()) / static_cast<double>(total)) * 100.0;
152 }

References allocation_failures, and total_allocations.

◆ operator=() [1/2]

memory_pool_statistics & kcenon::monitoring::memory_pool_statistics::operator= ( const memory_pool_statistics & other)
inline

Definition at line 116 of file memory_pool.h.

116 {
117 if (this != &other) {
118 total_allocations.store(other.total_allocations.load());
119 total_deallocations.store(other.total_deallocations.load());
120 allocation_failures.store(other.allocation_failures.load());
121 peak_usage.store(other.peak_usage.load());
122 }
123 return *this;
124 }

References allocation_failures, kcenon::monitoring::other, peak_usage, total_allocations, and total_deallocations.

◆ operator=() [2/2]

memory_pool_statistics & kcenon::monitoring::memory_pool_statistics::operator= ( memory_pool_statistics && other)
inlinenoexcept

Definition at line 132 of file memory_pool.h.

132 {
133 if (this != &other) {
134 total_allocations.store(other.total_allocations.load());
135 total_deallocations.store(other.total_deallocations.load());
136 allocation_failures.store(other.allocation_failures.load());
137 peak_usage.store(other.peak_usage.load());
138 }
139 return *this;
140 }

References allocation_failures, kcenon::monitoring::other, peak_usage, total_allocations, and total_deallocations.

◆ reset()

void kcenon::monitoring::memory_pool_statistics::reset ( )
inline

Reset all statistics.

Definition at line 157 of file memory_pool.h.

157 {
158 total_allocations.store(0);
159 total_deallocations.store(0);
160 allocation_failures.store(0);
161 peak_usage.store(0);
162 }

References allocation_failures, peak_usage, total_allocations, and total_deallocations.

Referenced by kcenon::monitoring::memory_pool::reset_statistics().

Here is the caller graph for this function:

Member Data Documentation

◆ allocation_failures

std::atomic<size_t> kcenon::monitoring::memory_pool_statistics::allocation_failures {0}

◆ peak_usage

std::atomic<size_t> kcenon::monitoring::memory_pool_statistics::peak_usage {0}

Definition at line 107 of file memory_pool.h.

107{0};

Referenced by operator=(), operator=(), reset(), and kcenon::monitoring::memory_pool::update_peak_usage().

◆ total_allocations

std::atomic<size_t> kcenon::monitoring::memory_pool_statistics::total_allocations {0}

◆ total_deallocations

std::atomic<size_t> kcenon::monitoring::memory_pool_statistics::total_deallocations {0}

Definition at line 105 of file memory_pool.h.

105{0};

Referenced by kcenon::monitoring::memory_pool::deallocate(), operator=(), operator=(), and reset().


The documentation for this struct was generated from the following file: