#include <timer.h>
Definition at line 16 of file timer.h.
◆ Timer() [1/4]
Botan::Timer::Timer |
( |
const std::string & |
name, |
|
|
const std::string & |
provider, |
|
|
const std::string & |
doing, |
|
|
uint64_t |
event_mult, |
|
|
size_t |
buf_size, |
|
|
double |
clock_cycle_ratio, |
|
|
uint64_t |
clock_speed |
|
) |
| |
|
inline |
Definition at line 19 of file timer.h.
26 : m_name(
name + ((provider.empty() || provider ==
"base") ?
"" :
" [" + provider +
"]"))
29 , m_event_mult(event_mult)
30 , m_clock_cycle_ratio(clock_cycle_ratio)
31 , m_clock_speed(clock_speed)
32 {}
const std::string & doing() const
◆ Timer() [2/4]
Botan::Timer::Timer |
( |
const std::string & |
name | ) |
|
|
inline |
Definition at line 34 of file timer.h.
34 :
36 {}
Timer(const std::string &name, const std::string &provider, const std::string &doing, uint64_t event_mult, size_t buf_size, double clock_cycle_ratio, uint64_t clock_speed)
◆ Timer() [3/4]
Botan::Timer::Timer |
( |
const std::string & |
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 110 of file timer.h.
111 {
112 if(m_clock_speed != 0)
113 {
114 return static_cast<uint64_t
>((m_clock_speed *
value()) / 1000.0);
115 }
116 return m_cpu_cycles_used;
117 }
◆ 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 100 of file timer.h.
101 {
102 return value() / 1000000.0;
103 }
◆ ms_per_event()
double Botan::Timer::ms_per_event |
( |
| ) |
const |
|
inline |
Definition at line 105 of file timer.h.
106 {
108 }
double milliseconds() const
◆ operator<()
bool Botan::Timer::operator< |
( |
const Timer & |
other | ) |
const |
Definition at line 59 of file timer.cpp.
60 {
61 if(this->
doing() != other.doing())
62 return (this->
doing() < other.doing());
63
64 return (this->
get_name() < other.get_name());
65 }
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 75 of file timer.h.
76 {
77 Timer_Scope timer(*this);
78 return f();
79 }
◆ 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 |
( |
const std::string & |
s | ) |
|
|
inline |
Definition at line 154 of file timer.h.
155 {
156 m_custom_msg = s;
157 }
◆ start()
void Botan::Timer::start |
( |
| ) |
|
◆ stop()
void Botan::Timer::stop |
( |
| ) |
|
Definition at line 22 of file timer.cpp.
23 {
24 if(m_timer_start)
25 {
26 if(m_cpu_cycles_start != 0)
27 {
29 if(cycles_taken > 0)
30 {
31 m_cpu_cycles_used += static_cast<size_t>(cycles_taken * m_clock_cycle_ratio);
32 }
33 }
34
36
37 if(now > m_timer_start)
38 {
39 const uint64_t dur = now - m_timer_start;
40
41 m_time_used += dur;
42
43 if(m_event_count == 0)
44 {
45 m_min_time = m_max_time = dur;
46 }
47 else
48 {
49 m_max_time = std::max(m_max_time, dur);
50 m_min_time = std::min(m_min_time, dur);
51 }
52 }
53
54 m_timer_start = 0;
55 ++m_event_count;
56 }
57 }
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 67 of file timer.cpp.
68 {
69 if(m_custom_msg.size() > 0)
70 {
71 return m_custom_msg;
72 }
74 {
75 return result_string_ops();
76 }
77 else
78 {
79 return result_string_bps();
80 }
81 }
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: