xtd 0.2.0
Loading...
Searching...
No Matches
stopwatch.h
Go to the documentation of this file.
1
4#pragma once
5#include <string>
6#include "../object.h"
7#include "../time_span.h"
8
10namespace xtd {
12 namespace diagnostics {
35 public:
37
45 stopwatch() = default;
47
49 stopwatch(const stopwatch&) = default;
50 stopwatch& operator =(const stopwatch&) = default;
52
54
66 time_span elapsed() const noexcept;
67
76 int64 elapsed_milliseconds() const noexcept;
77
83 int64 elapsed_nanoseconds() const noexcept;
84
93 int64 elapsed_ticks() const noexcept;
94
98 bool is_running() const noexcept;
100
102
106 static int64 frequency() noexcept;
107
112 static bool is_high_resolution() noexcept;
114
116
120 void reset() noexcept;
121
124 void restart() noexcept;
125
133 void start() noexcept;
134
140 static stopwatch start_new() noexcept;
141
149 void stop() noexcept;
151
153
157 static std::chrono::nanoseconds get_timestamp() noexcept;
158
161 static int64 get_timestamp_milliseconds() noexcept;
162
165 static int64 get_timestamp_nanoseconds() noexcept;
166
169 static int64 get_timestamp_ticks() noexcept;
171
172 private:
173 explicit stopwatch(bool start);
174 bool running_ = false;
175 int64 start_ = 0;
176 int64 stop_ = 0;
177 };
178 }
179}
Provides a set of methods and properties that you can use to accurately measure elapsed time.
Definition stopwatch.h:34
time_span elapsed() const noexcept
Gets the total elapsed time measured by the current instance.
stopwatch()=default
Initializes a new instance of the xtd::diagnostics::stopwatch class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
#define core_export_
Define shared library export.
Definition core_export.h:13
int_least64_t int64
Represents a 64-bit signed integer.
Definition types.h:142
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Represents a time interval.
Definition time_span.h:26