24#ifndef SLEIPNIR_DISABLE_DIAGNOSTICS
25 m_setup_start_time = std::chrono::steady_clock::now();
31#ifndef SLEIPNIR_DISABLE_DIAGNOSTICS
32 m_setup_stop_time = std::chrono::steady_clock::now();
33 m_setup_duration = m_setup_stop_time - m_setup_start_time;
40 std::string_view
name()
const {
return m_name; }
45 const std::chrono::duration<double>&
duration()
const {
46 return m_setup_duration;
53 std::chrono::steady_clock::time_point m_setup_start_time;
54 std::chrono::steady_clock::time_point m_setup_stop_time;
55 std::chrono::duration<double> m_setup_duration{0.0};
69#ifndef SLEIPNIR_DISABLE_DIAGNOSTICS
70 m_current_solve_start_time = std::chrono::steady_clock::now();
77#ifndef SLEIPNIR_DISABLE_DIAGNOSTICS
78 m_current_solve_stop_time = std::chrono::steady_clock::now();
79 m_current_solve_duration =
80 m_current_solve_stop_time - m_current_solve_start_time;
81 m_total_solve_duration += m_current_solve_duration;
84 m_average_solve_duration =
85 (m_num_solves - 1.0) / m_num_solves * m_average_solve_duration +
86 1.0 / m_num_solves * m_current_solve_duration;
93 std::string_view
name()
const {
return m_name; }
104 return m_current_solve_duration;
111 return m_average_solve_duration;
118 return m_total_solve_duration;
125 std::chrono::steady_clock::time_point m_current_solve_start_time;
126 std::chrono::steady_clock::time_point m_current_solve_stop_time;
127 std::chrono::duration<double> m_current_solve_duration{0.0};
128 std::chrono::duration<double> m_total_solve_duration{0.0};
130 int m_num_solves = 0;
131 std::chrono::duration<double> m_average_solve_duration{0.0};
135template <
typename Profiler>
136 requires std::same_as<Profiler, SetupProfiler> ||
137 std::same_as<Profiler, SolveProfiler>
158 : m_profiler{std::move(
rhs.m_profiler)}, m_active{
rhs.m_active} {
159 rhs.m_active =
false;
179 return m_profiler->current_duration();
184 bool m_active =
true;
Definition intrusive_shared_ptr.hpp:27
Starts a profiler in the constructor and stops it in the destructor.
Definition profiler.hpp:138
ScopedProfiler(ScopedProfiler &&rhs) noexcept
Definition profiler.hpp:157
void stop()
Definition profiler.hpp:168
~ScopedProfiler()
Stops a profiler.
Definition profiler.hpp:148
ScopedProfiler(Profiler &profiler) noexcept
Definition profiler.hpp:143
const std::chrono::duration< double > & current_duration() const
Definition profiler.hpp:178
Definition profiler.hpp:15
const std::chrono::duration< double > & duration() const
Definition profiler.hpp:45
SetupProfiler(std::string_view name)
Definition profiler.hpp:20
std::string_view name() const
Definition profiler.hpp:40
void stop()
Tell the profiler to stop measuring setup time.
Definition profiler.hpp:30
void start()
Tell the profiler to start measuring setup time.
Definition profiler.hpp:23
Definition profiler.hpp:60
const std::chrono::duration< double > & average_duration() const
Definition profiler.hpp:110
const std::chrono::duration< double > & current_duration() const
Definition profiler.hpp:103
SolveProfiler(std::string_view name)
Definition profiler.hpp:65
const std::chrono::duration< double > & total_duration() const
Definition profiler.hpp:117
std::string_view name() const
Definition profiler.hpp:93
void start()
Tell the profiler to start measuring solve time.
Definition profiler.hpp:68
int num_solves() const
Definition profiler.hpp:98
void stop()
Definition profiler.hpp:76