smats  0.0.1
Satisfability Modulo Arithmetic Theories Symbols
Loading...
Searching...
No Matches
stats.h
1
10#pragma once
11
12#include <atomic>
13#include <iostream>
14#include <string>
15
16#include "smats/util/timer.h"
17
18namespace smats {
19
25class Stats {
26 public:
38 explicit Stats(bool enabled, std::string class_name, std::string name_time = "Time spent in Operations");
39 Stats(const Stats &other) = default;
40 Stats &operator=(const Stats &other) = default;
41 virtual ~Stats() = default;
42
43 Stats &operator+=(const Stats &other);
44 Stats operator+(const Stats &other) const;
45
47 [[nodiscard]] bool enabled() const { return enabled_; }
49 [[nodiscard]] Timer &m_timer() { return timer_; }
51 [[nodiscard]] const Timer &timer() const { return timer_; }
57 [[nodiscard]] virtual std::string to_segment_string() const;
62 [[nodiscard]] virtual std::string to_string() const;
63
64 protected:
65 bool enabled_;
66 std::string class_name_;
67 std::string operations_name_;
68
69 private:
71};
72
78class IterationStats : public Stats {
79 public:
92 explicit IterationStats(bool enabled, std::string class_name, std::string name_time = "Time spent in Operations",
93 std::string iterations_name = "Total # of Iterations");
94 IterationStats(const IterationStats &other);
95 IterationStats &operator=(const IterationStats &other);
96
97 IterationStats &operator+=(const IterationStats &other);
98 IterationStats operator+(const IterationStats &other) const;
99
100 [[nodiscard]] std::string to_segment_string() const override;
101
102 [[nodiscard]] std::string to_string() const override;
103
108 void increase();
109
110 [[nodiscard]] unsigned int iterations() const { return iterations_.load(); }
111
112 void operator++();
113 void operator++(int);
114
115 private:
116 std::atomic<unsigned int> iterations_;
117 std::string iterations_name_;
118};
119
120std::ostream &operator<<(std::ostream &os, const Stats &stats);
121std::ostream &operator<<(std::ostream &os, const IterationStats &stats);
122
123} // namespace smats
Definition stats.h:78
std::string to_string() const override
Definition stats.cpp:45
std::atomic< unsigned int > iterations_
Number of iterations.
Definition stats.h:116
void increase()
Definition stats.cpp:38
IterationStats(bool enabled, std::string class_name, std::string name_time="Time spent in Operations", std::string iterations_name="Total # of Iterations")
Definition stats.cpp:49
std::string to_segment_string() const override
Definition stats.cpp:42
std::string iterations_name_
Prompt to specify the number of iterations.
Definition stats.h:117
Definition stats.h:25
virtual std::string to_string() const
Definition stats.cpp:24
bool enabled() const
Definition stats.h:47
Stats(bool enabled, std::string class_name, std::string name_time="Time spent in Operations")
Definition stats.cpp:18
Timer timer_
Timer to measure the time spent in operations.
Definition stats.h:70
std::string operations_name_
Prompt to specify what operation the time has been measured of.
Definition stats.h:67
const Timer & timer() const
Definition stats.h:51
std::string class_name_
Name of the class the stats are measuring.
Definition stats.h:66
bool enabled_
Whether the stats measuring is enabled.
Definition stats.h:65
Timer & m_timer()
Definition stats.h:49
virtual std::string to_segment_string() const
Definition stats.cpp:21
Definition timer.h:80
ExpressionKind enum.