qxLib
benchmark.h
Go to the documentation of this file.
1 /**
2 
3  @file benchmark.h
4  @author Khrapov
5  @date 2.02.2020
6  @copyright © Nick Khrapov, 2021. All right reserved.
7 
8 **/
9 #pragma once
10 
11 #include <chrono>
12 
13 namespace qx
14 {
15 
16 /**
17 
18  @class benchmark
19  @brief Benchmark class
20  @author Khrapov
21  @date 2.02.2020
22 
23 **/
24 class benchmark
25 {
26 public:
27  using clock = std::chrono::steady_clock;
28  using time_point = clock::time_point;
29  using duration = std::chrono::nanoseconds;
30 
31  /**
32  @brief Start benchmark
33  **/
34  void start();
35 
36  /**
37  @brief End benchmark
38  @retval - number of seconds since start time
39  **/
40  double end();
41 
42  /**
43  @brief Get last benchmark time
44  @retval - last number of seconds since start time
45  **/
46  double last() const;
47 
48 private:
49  time_point m_Start;
50  duration m_LastDuration = duration(0);
51 };
52 
53 } // namespace qx
54 
55 #include <qx/stat/benchmark.inl>
Benchmark class.
Definition: benchmark.h:25
void start()
Start benchmark.
Definition: benchmark.inl:13
double last() const
Get last benchmark time.
Definition: benchmark.inl:24
double end()
End benchmark.
Definition: benchmark.inl:18