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 {
37 public:
39
47 stopwatch() = default;
49
51 stopwatch(const stopwatch&) = default;
52 stopwatch& operator =(const stopwatch&) = default;
54
56
68 time_span elapsed() const noexcept;
69
78 int64 elapsed_milliseconds() const noexcept;
79
85 int64 elapsed_nanoseconds() const noexcept;
86
95 int64 elapsed_ticks() const noexcept;
96
100 bool is_running() const noexcept;
102
104
108 static int64 frequency() noexcept;
109
114 static bool is_high_resolution() noexcept;
116
118
122 void reset() noexcept;
123
126 void restart() noexcept;
127
135 void start() noexcept;
136
142 static stopwatch start_new() noexcept;
143
151 void stop() noexcept;
153
155
159 static std::chrono::nanoseconds get_timestamp() noexcept;
160
163 static int64 get_timestamp_milliseconds() noexcept;
164
167 static int64 get_timestamp_nanoseconds() noexcept;
168
171 static int64 get_timestamp_ticks() noexcept;
173
174 private:
175 explicit stopwatch(bool start);
176 bool running_ = false;
177 int64 start_ = 0;
178 int64 stop_ = 0;
179 };
180 }
181}
Provides a set of methods and properties that you can use to accurately measure elapsed time.
Definition stopwatch.h:36
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:42
#define core_export_
Define shared library export.
Definition core_export.h:13
int64_t int64
Represents a 64-bit signed integer.
Definition int64.h:23
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:29