Clock object based on std::chrono::high_resolution_clock.
More...
#include <clock.hh>
|
void | tick () |
| Start the timer.
|
|
void | tock () |
| Stop the timer.
|
|
void | reset () |
|
size_t | ns () const |
|
const std::string | summarize () const |
| Total time elapsed.
|
|
void | reconcile () |
| Prepare clock object to calculate percentile/summary. More...
|
|
size_t | percentile (const size_t pc) const |
| Calculate the percentile value. More...
|
|
std::string | summarize (size_t total_ops, bool distribution=false) const |
| Summary with operations per second. More...
|
|
size_t | ns_per_op (size_t total_ops) const |
|
size_t | percentile_per_op (const size_t total_ops, const size_t pc) const |
|
|
std::chrono::system_clock::time_point | start_clk |
|
bool | running = false |
|
size_t | total_ns = 0 |
|
std::vector< size_t > | raw_values |
|
std::vector< size_t > | sorted_raw_values |
|
|
static constexpr size_t | RAW_VAL_CNT = 1024*1024*100 |
|
Clock object based on std::chrono::high_resolution_clock.
Definition at line 38 of file clock.hh.
◆ percentile()
size_t nvsl::Clock::percentile |
( |
const size_t |
pc | ) |
const |
|
inline |
Calculate the percentile value.
- Parameters
-
[in] | pc | Percentile out of 100 |
Definition at line 125 of file clock.hh.
127 #if defined(NVSL_ERROR)
128 NVSL_ERROR(
"Clock not reconcile. Call reconcile()");
130 assert(0 &&
"Clock not reconciled. Call reconcile()");
135 const auto idx = std::max(0UL, (
size_t)((sz*pc)/100.0)-1);
◆ reconcile()
void nvsl::Clock::reconcile |
( |
| ) |
|
|
inline |
Prepare clock object to calculate percentile/summary.
non-const function to update the internal state so that other functions can be const
Definition at line 114 of file clock.hh.
116 std::copy(raw_values.begin(), raw_values.end(),
◆ summarize()
std::string nvsl::Clock::summarize |
( |
size_t |
total_ops, |
|
|
bool |
distribution = false |
|
) |
| const |
|
inline |
Summary with operations per second.
- Parameters
-
[in] | total_ops | Total number of operations performed |
[in] | distribution | Generate distribution in summary |
Definition at line 145 of file clock.hh.
146 std::stringstream ss;
149 NVSL_ASSERT(total_ops != 0,
"total ops cannot be zero");
151 assert(total_ops != 0 &&
"Total ops cannot be zero");
154 size_t ops_per_iter = total_ops/raw_values.size();
156 <<
"ops/s: " << (total_ops * (1000000000)) / ((double)this->ns())
159 << ns_to_hr_clk((
size_t)(this->ns() / (double)total_ops))
161 << ns_to_hr_clk((
size_t)(this->
percentile(50))/ops_per_iter)
163 << ns_to_hr_clk((
size_t)(this->
percentile(90))/ops_per_iter)
165 << ns_to_hr_clk((
size_t)(this->
percentile(99))/ops_per_iter)
167 << ns_to_hr_clk((
size_t)(this->ns() / (
double)total_ops));
◆ sorted_raw_values
std::vector<size_t> nvsl::Clock::sorted_raw_values |
|
private |
Total number of values to store
Definition at line 44 of file clock.hh.
The documentation for this class was generated from the following file: