#include <timer.h>
Definition at line 16 of file timer.h.
◆ Timer() [1/4]
Botan::Timer::Timer |
( |
std::string_view |
name, |
|
|
std::string_view |
provider, |
|
|
std::string_view |
doing, |
|
|
uint64_t |
event_mult, |
|
|
size_t |
buf_size, |
|
|
double |
clock_cycle_ratio, |
|
|
uint64_t |
clock_speed |
|
) |
| |
Definition at line 30 of file timer.cpp.
37 : m_name(format_timer_name(
name, provider))
40 , m_event_mult(event_mult)
41 , m_clock_cycle_ratio(clock_cycle_ratio)
42 , m_clock_speed(clock_speed)
43 {}
const std::string doing() const
◆ Timer() [2/4]
Botan::Timer::Timer |
( |
std::string_view |
name | ) |
|
|
inline |
Definition at line 27 of file timer.h.
27 :
29 {}
Timer(std::string_view name, std::string_view provider, std::string_view doing, uint64_t event_mult, size_t buf_size, double clock_cycle_ratio, uint64_t clock_speed)
◆ Timer() [3/4]
Botan::Timer::Timer |
( |
std::string_view |
name, |
|
|
size_t |
buf_size |
|
) |
| |
|
inline |
◆ Timer() [4/4]
Botan::Timer::Timer |
( |
const Timer & |
other | ) |
|
|
default |
◆ buf_size()
size_t Botan::Timer::buf_size |
( |
| ) |
const |
|
inline |
◆ bytes_per_second()
double Botan::Timer::bytes_per_second |
( |
| ) |
const |
|
inline |
◆ cycles_consumed()
uint64_t Botan::Timer::cycles_consumed |
( |
| ) |
const |
|
inline |
Definition at line 104 of file timer.h.
105 {
106 if(m_clock_speed != 0)
107 {
108 return static_cast<uint64_t
>((m_clock_speed *
value()) / 1000.0);
109 }
110 return m_cpu_cycles_used;
111 }
◆ doing()
const std::string Botan::Timer::doing |
( |
| ) |
const |
|
inline |
◆ events()
uint64_t Botan::Timer::events |
( |
| ) |
const |
|
inline |
◆ events_per_second()
double Botan::Timer::events_per_second |
( |
| ) |
const |
|
inline |
◆ get_name()
const std::string Botan::Timer::get_name |
( |
| ) |
const |
|
inline |
◆ milliseconds()
double Botan::Timer::milliseconds |
( |
| ) |
const |
|
inline |
Definition at line 94 of file timer.h.
95 {
96 return value() / 1000000.0;
97 }
◆ ms_per_event()
double Botan::Timer::ms_per_event |
( |
| ) |
const |
|
inline |
Definition at line 99 of file timer.h.
100 {
102 }
double milliseconds() const
◆ operator<()
bool Botan::Timer::operator< |
( |
const Timer & |
other | ) |
const |
Definition at line 89 of file timer.cpp.
90 {
91 if(this->
doing() != other.doing())
92 return (this->
doing() < other.doing());
93
94 return (this->
get_name() < other.get_name());
95 }
const std::string get_name() const
References doing(), and get_name().
◆ operator=()
Timer & Botan::Timer::operator= |
( |
const Timer & |
other | ) |
|
|
default |
◆ run()
template<typename F >
auto Botan::Timer::run |
( |
F |
f | ) |
-> decltype(f())
|
|
inline |
Definition at line 69 of file timer.h.
70 {
71 Timer_Scope timer(*this);
72 return f();
73 }
◆ run_until_elapsed()
template<typename F >
void Botan::Timer::run_until_elapsed |
( |
std::chrono::milliseconds |
msec, |
|
|
F |
f |
|
) |
| |
|
inline |
◆ seconds()
double Botan::Timer::seconds |
( |
| ) |
const |
|
inline |
◆ seconds_per_event()
double Botan::Timer::seconds_per_event |
( |
| ) |
const |
|
inline |
◆ set_custom_msg()
void Botan::Timer::set_custom_msg |
( |
std::string_view |
s | ) |
|
|
inline |
Definition at line 148 of file timer.h.
149 {
150 m_custom_msg = s;
151 }
◆ start()
void Botan::Timer::start |
( |
| ) |
|
◆ stop()
void Botan::Timer::stop |
( |
| ) |
|
Definition at line 52 of file timer.cpp.
53 {
54 if(m_timer_start)
55 {
56 if(m_cpu_cycles_start != 0)
57 {
59 if(cycles_taken > 0)
60 {
61 m_cpu_cycles_used += static_cast<size_t>(cycles_taken * m_clock_cycle_ratio);
62 }
63 }
64
66
67 if(now > m_timer_start)
68 {
69 const uint64_t dur = now - m_timer_start;
70
71 m_time_used += dur;
72
73 if(m_event_count == 0)
74 {
75 m_min_time = m_max_time = dur;
76 }
77 else
78 {
79 m_max_time = std::max(m_max_time, dur);
80 m_min_time = std::min(m_min_time, dur);
81 }
82 }
83
84 m_timer_start = 0;
85 ++m_event_count;
86 }
87 }
References Botan::OS::get_cpu_cycle_counter(), and Botan::OS::get_system_timestamp_ns().
Referenced by start().
◆ to_string()
std::string Botan::Timer::to_string |
( |
| ) |
const |
Definition at line 97 of file timer.cpp.
98 {
99 if(!m_custom_msg.empty())
100 {
101 return m_custom_msg;
102 }
104 {
105 return result_string_ops();
106 }
107 else
108 {
109 return result_string_bps();
110 }
111 }
References buf_size().
◆ under()
bool Botan::Timer::under |
( |
std::chrono::milliseconds |
msec | ) |
|
|
inline |
◆ value()
uint64_t Botan::Timer::value |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: