10#include <botan/types.h>
20 std::string_view provider,
21 std::string_view doing,
24 double clock_cycle_ratio,
25 uint64_t clock_speed);
32 Timer(
name,
"",
"", buf_size, buf_size, 0.0, 0)
42 bool under(std::chrono::milliseconds msec)
45 return (milliseconds() < msec.count());
69 auto run(F f) ->
decltype(f())
78 while(this->under(msec))
91 return milliseconds() / 1000.0;
96 return value() / 1000000.0;
101 return milliseconds() / events();
106 if(m_clock_speed != 0)
108 return static_cast<uint64_t
>((m_clock_speed * value()) / 1000.0);
110 return m_cpu_cycles_used;
115 return m_event_count * m_event_mult;
135 return seconds() > 0.0 ? events() / seconds() : 0.0;
140 return seconds() > 0.0 ? events() / seconds() : 0.0;
145 return events() > 0 ? seconds() / events() : 0.0;
155 std::string to_string()
const;
158 std::string result_string_bps()
const;
159 std::string result_string_ops()
const;
162 std::string m_name, m_doing;
164 uint64_t m_event_mult;
165 double m_clock_cycle_ratio;
166 uint64_t m_clock_speed;
169 std::string m_custom_msg;
170 uint64_t m_time_used = 0, m_timer_start = 0;
171 uint64_t m_event_count = 0;
173 uint64_t m_max_time = 0, m_min_time = 0;
174 uint64_t m_cpu_cycles_start = 0, m_cpu_cycles_used = 0;
Timer_Scope(Timer &timer)
double milliseconds() const
Timer(std::string_view name, size_t buf_size)
double events_per_second() const
bool under(std::chrono::milliseconds msec)
uint64_t cycles_consumed() const
Timer & operator=(const Timer &other)=default
Timer(std::string_view name)
double ms_per_event() const
double seconds_per_event() const
const std::string doing() const
auto run(F f) -> decltype(f())
Timer(const Timer &other)=default
void set_custom_msg(std::string_view s)
void run_until_elapsed(std::chrono::milliseconds msec, F f)
const std::string get_name() const
double bytes_per_second() const
int(* final)(unsigned char *, CTX *)
bool operator<(const OID &a, const OID &b)