#include <metrics.h>
Public Member Functions | |
Metrics (metric::Token token) | |
const metric::Group & | group () const |
metric::Group & | group () |
const MetricsType & | metrics () const |
void | ModifyRequested (size_t increase, size_t decrease) |
void | ModifyAllocated (size_t increase, size_t decrease) |
void | IncrementAllocations () |
Records that a call to Allocate was made. | |
void | IncrementDeallocations () |
Records that a call to Deallocate was made. | |
void | IncrementResizes () |
Records that a call to Resize was made. | |
void | IncrementReallocations () |
Records that a call to Reallocate was made. | |
void | RecordFailure (size_t requested) |
void | UpdateDeferred (Allocator &allocator) |
Encapsulates the metrics struct for pw::allocator::TrackingAllocator
.
This class uses the type traits from PW_ALLOCATOR_METRICS_DECLARE
to conditionally include or exclude code to update metrics based on calls to the pw::Allocator
API. This minimizes code size without adding additional conditions to be evaluated at runtime.
MetricsType | The struct defining which metrics are enabled. |
void pw::allocator::internal::Metrics< MetricsType >::ModifyAllocated | ( | size_t | increase, |
size_t | decrease | ||
) |
Updates how much memory is allocated.
This will update the current, peak, and cumulative amounts of memory that has been actually allocated or freed. This method acts as if it frees memory before allocating. If a routine suchas Reallocate
allocates before freeing, the update should be separated into two calls, e.g.
increase | How much memory was allocated. |
decrease | How much memory was freed. |
void pw::allocator::internal::Metrics< MetricsType >::ModifyRequested | ( | size_t | increase, |
size_t | decrease | ||
) |
Updates how much memory was requested and successfully allocated.
This will update the current, peak, and cumulative amounts of memory requests that were satisfied by an allocator.
increase | How much memory was requested to be allocated. |
decrease | How much memory was requested to be freed. |
void pw::allocator::internal::Metrics< MetricsType >::RecordFailure | ( | size_t | requested | ) |
Records that a call to Allocate
, Resize
, or Reallocate
failed.
This may indicated that memory becoming exhausted and/or highly fragmented.
requested | How much memory was requested in the failed call. |
|
inline |
Updates metrics by querying an allocator directly.
See also NoMetrics::UpdateDeferred
.