xtd 0.2.0
stopwatch.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <string>
6#include "../object.hpp"
7#include "../time_span.hpp"
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
164
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}
static std::chrono::nanoseconds get_timestamp() noexcept
Gets the current number of nanoseconds in the timer mechanism.
void stop() noexcept
Stops measuring elapsed time for an interval.
void reset() noexcept
Stops time interval measurement and resets the elapsed time to zero.
int64 elapsed_ticks() const noexcept
Gets the total elapsed time measured by the current instance, in timer ticks.
time_span elapsed() const noexcept
Gets the total elapsed time measured by the current instance.
static int64 frequency() noexcept
Gets the frequency of the timer as the number of nanoseconds per second. This field is read-only.
static int64 get_timestamp_nanoseconds() noexcept
Gets the current number of nanoseconds in the timer mechanism, in nanoseconds.
void start() noexcept
Starts, or resumes, measuring elapsed time for an interval.
static int64 get_timestamp_milliseconds() noexcept
Gets the current number of nanoseconds in the timer mechanism, in milliseconds.
static int64 get_timestamp_ticks() noexcept
Gets the current number of nanoseconds in the timer mechanism, in ticks.
stopwatch()=default
Initializes a new instance of the xtd::diagnostics::stopwatch class.
int64 elapsed_milliseconds() const noexcept
Gets the total elapsed time measured by the current instance, in milliseconds.
static stopwatch start_new() noexcept
Initializes a new xtd::diagnostics::stopwatch instance, sets the xtd::diagnostics::stopwatch::elapsed...
bool is_running() const noexcept
Gets a value indicating whether the stopwatch timer is running.
int64 elapsed_nanoseconds() const noexcept
Gets the total elapsed time measured by the current instance, in nanoseconds.
static bool is_high_resolution() noexcept
Indicates whether the timer is based on a high-resolution performance counter. This field is read-onl...
void restart() noexcept
stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents a time interval.
Definition time_span.hpp:29
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::object class.
Contains xtd::time_span class.