14#include "delpi/util/Timer.h"
38 explicit Stats(
bool enabled, std::string class_name, std::string name_time =
"Time spent in Operations");
40 Stats &operator=(
const Stats &other) =
default;
41 virtual ~Stats() =
default;
47 [[nodiscard]]
bool enabled()
const {
return enabled_; }
51 [[nodiscard]]
const Timer &timer()
const {
return timer_; }
53 [[nodiscard]]
const std::string &class_name()
const {
return class_name_; }
64 [[nodiscard]]
virtual std::string
ToString()
const;
84 explicit IterationStats(
bool enabled, std::string class_name, std::string name_time =
"Time spent in Operations",
85 std::string iterations_name =
"Total # of Iterations");
94 [[nodiscard]] std::string
ToString()
const override;
103 [[nodiscard]]
unsigned int iterations()
const {
return iterations_.load(); }
111 void operator++(
int);
114std::ostream &operator<<(std::ostream &os,
const Stats &stats);
115std::ostream &operator<<(std::ostream &os,
const IterationStats &stats);
119#ifdef DELPI_INCLUDE_FMT
121#include "delpi/util/logging.h"
Dataclass collecting statistics about some operation or process.
IterationStats(bool enabled, std::string class_name, std::string name_time="Time spent in Operations", std::string iterations_name="Total # of Iterations")
Construct an IterationStats object.
std::string ToString() const override
Convert the current state of the object to a formatted string.
std::atomic< unsigned int > iterations_
Atomic counter for the total number of iterations.
std::string iterations_name_
Name to give to the iteration operation.
void Increase()
Increase the iteration counter by one.
std::string ToSegmentString() const override
Convert the current state of the object to a formatted string, only including the specific part the S...
void SetIterations(const unsigned int iterations)
Set the total number of iterations.
Dataclass collecting statistics about some operation or process.
virtual std::string ToString() const
Convert the current state of the object to a formatted string.
std::string class_name_
Name of the class running the operation the Stats object is collecting statistics for.
Stats(bool enabled, std::string class_name, std::string name_time="Time spent in Operations")
Construct a Stats object.
virtual std::string ToSegmentString() const
Convert the current state of the object to a formatted string, only including the specific part the S...
Timer timer_
Timer object to measure the cumulative time spent in the operation.
bool enabled_
Flag to enable/disable the collection of statistics.
std::string operations_name_
Name of the operation the Stats object is collecting statistics for.
Timer class using the a steady clock.
Global namespace for the delpi library.