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

Statistics for ring buffer performance monitoring. More...

#include <ring_buffer.h>

Collaboration diagram for kcenon::monitoring::ring_buffer_stats:
Collaboration graph

Public Member Functions

 ring_buffer_stats ()
 
double get_utilization (size_t current_size, size_t capacity) const
 Get current utilization percentage.
 
double get_write_success_rate () const
 Get write success rate.
 
double get_overflow_rate () const
 Get overflow rate (overwrites per total writes)
 
bool is_overflow_rate_high () const
 Check if overflow rate is high (> 10%)
 
double get_avg_contention () const
 Get average contention (retries per write)
 
double get_read_success_rate () const
 Get read success rate.
 

Public Attributes

std::atomic< size_t > total_writes {0}
 
std::atomic< size_t > total_reads {0}
 
std::atomic< size_t > overwrites {0}
 
std::atomic< size_t > failed_writes {0}
 
std::atomic< size_t > failed_reads {0}
 
std::atomic< size_t > contention_retries {0}
 
std::chrono::system_clock::time_point creation_time
 

Detailed Description

Statistics for ring buffer performance monitoring.

Definition at line 64 of file ring_buffer.h.

Constructor & Destructor Documentation

◆ ring_buffer_stats()

kcenon::monitoring::ring_buffer_stats::ring_buffer_stats ( )
inline

Definition at line 73 of file ring_buffer.h.

73: creation_time(std::chrono::system_clock::now()) {}
std::chrono::system_clock::time_point creation_time
Definition ring_buffer.h:71

Member Function Documentation

◆ get_avg_contention()

double kcenon::monitoring::ring_buffer_stats::get_avg_contention ( ) const
inline

Get average contention (retries per write)

Definition at line 110 of file ring_buffer.h.

110 {
111 auto total = total_writes.load();
112 auto retries = contention_retries.load();
113 return total > 0 ? static_cast<double>(retries) / total : 0.0;
114 }
std::atomic< size_t > contention_retries
Definition ring_buffer.h:70
std::atomic< size_t > total_writes
Definition ring_buffer.h:65

References contention_retries, and total_writes.

◆ get_overflow_rate()

double kcenon::monitoring::ring_buffer_stats::get_overflow_rate ( ) const
inline

Get overflow rate (overwrites per total writes)

Definition at line 94 of file ring_buffer.h.

94 {
95 auto total = total_writes.load();
96 auto overflows = overwrites.load();
97 return total > 0 ? (static_cast<double>(overflows) / total) * 100.0 : 0.0;
98 }

References overwrites, and total_writes.

Referenced by kcenon::monitoring::ring_buffer< T >::get_overflow_rate(), and is_overflow_rate_high().

Here is the caller graph for this function:

◆ get_read_success_rate()

double kcenon::monitoring::ring_buffer_stats::get_read_success_rate ( ) const
inline

Get read success rate.

Definition at line 119 of file ring_buffer.h.

119 {
120 auto total = total_reads.load();
121 auto failed = failed_reads.load();
122 return total > 0 ? (1.0 - static_cast<double>(failed) / total) * 100.0 : 100.0;
123 }
std::atomic< size_t > failed_reads
Definition ring_buffer.h:69
std::atomic< size_t > total_reads
Definition ring_buffer.h:66

References failed_reads, and total_reads.

◆ get_utilization()

double kcenon::monitoring::ring_buffer_stats::get_utilization ( size_t current_size,
size_t capacity ) const
inline

Get current utilization percentage.

Definition at line 78 of file ring_buffer.h.

78 {
79 return capacity > 0 ? (static_cast<double>(current_size) / capacity) * 100.0 : 0.0;
80 }

◆ get_write_success_rate()

double kcenon::monitoring::ring_buffer_stats::get_write_success_rate ( ) const
inline

Get write success rate.

Definition at line 85 of file ring_buffer.h.

85 {
86 auto total = total_writes.load();
87 auto failed = failed_writes.load();
88 return total > 0 ? (1.0 - static_cast<double>(failed) / total) * 100.0 : 100.0;
89 }
std::atomic< size_t > failed_writes
Definition ring_buffer.h:68

References failed_writes, and total_writes.

◆ is_overflow_rate_high()

bool kcenon::monitoring::ring_buffer_stats::is_overflow_rate_high ( ) const
inline

Check if overflow rate is high (> 10%)

Definition at line 103 of file ring_buffer.h.

103 {
104 return get_overflow_rate() > 10.0;
105 }
double get_overflow_rate() const
Get overflow rate (overwrites per total writes)
Definition ring_buffer.h:94

References get_overflow_rate().

Referenced by kcenon::monitoring::ring_buffer< T >::is_overflow_rate_high().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ contention_retries

std::atomic<size_t> kcenon::monitoring::ring_buffer_stats::contention_retries {0}

Definition at line 70 of file ring_buffer.h.

70{0};

Referenced by get_avg_contention(), and kcenon::monitoring::ring_buffer< T >::reset_stats().

◆ creation_time

std::chrono::system_clock::time_point kcenon::monitoring::ring_buffer_stats::creation_time

Definition at line 71 of file ring_buffer.h.

Referenced by kcenon::monitoring::ring_buffer< T >::reset_stats().

◆ failed_reads

std::atomic<size_t> kcenon::monitoring::ring_buffer_stats::failed_reads {0}

◆ failed_writes

std::atomic<size_t> kcenon::monitoring::ring_buffer_stats::failed_writes {0}

◆ overwrites

std::atomic<size_t> kcenon::monitoring::ring_buffer_stats::overwrites {0}

◆ total_reads

std::atomic<size_t> kcenon::monitoring::ring_buffer_stats::total_reads {0}

◆ total_writes

std::atomic<size_t> kcenon::monitoring::ring_buffer_stats::total_writes {0}

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