xtd 0.2.0
stopwatch.h
Go to the documentation of this file.
1 #pragma once
5 #include <string>
6 #include "../object.h"
7 #include "../time_span.h"
8 
10 namespace xtd {
12  namespace diagnostics {
34  class core_export_ stopwatch : public xtd::object {
35  public:
37 
45  stopwatch() = default;
47 
49  stopwatch(const stopwatch&) = default;
50  stopwatch& operator =(const stopwatch&) = default;
52 
54 
58  static int64 frequency() noexcept;
59 
64  static bool is_high_resolution() noexcept;
65 
76  time_span elapsed() const noexcept;
77 
86  int64 elapsed_milliseconds() const noexcept;
87 
93  int64 elapsed_nanoseconds() const noexcept;
94 
103  int64 elapsed_ticks() const noexcept;
104 
108  bool is_running() const noexcept;
110 
112 
116  static std::chrono::nanoseconds get_timestamp() noexcept;
117 
120  static int64 get_timestamp_milliseconds() noexcept;
121 
124  static int64 get_timestamp_nanoseconds() noexcept;
125 
128  static int64 get_timestamp_ticks() noexcept;
129 
132  void reset() noexcept;
133 
136  void restart() noexcept;
137 
145  void start() noexcept;
146 
152  static stopwatch start_new() noexcept;
153 
161  void stop() noexcept;
163 
164  private:
165  explicit stopwatch(bool start);
166  bool running_ = false;
167  int64 start_ = 0;
168  int64 stop_ = 0;
169  };
170  }
171 }
Stopping of a logical operation.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Provides a set of methods and properties that you can use to accurately measure elapsed time...
Definition: stopwatch.h:34
Starting of a logical operation.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
Represents a time interval.
Definition: time_span.h:26
int_least64_t int64
Represents a 64-bit signed integer.
Definition: types.h:140