Provides a set of methods and properties that you can use to accurately measure elapsed time.
Public Constructors | |
| stopwatch ()=default | |
| Initializes a new instance of the xtd::diagnostics::stopwatch class. | |
Public Properties | |
| auto | elapsed () const noexcept -> xtd::time_span |
| Gets the total elapsed time measured by the current instance. | |
| auto | elapsed_milliseconds () const noexcept -> xtd::int64 |
| Gets the total elapsed time measured by the current instance, in milliseconds. | |
| auto | elapsed_nanoseconds () const noexcept -> xtd::int64 |
| Gets the total elapsed time measured by the current instance, in nanoseconds. | |
| auto | elapsed_ticks () const noexcept -> xtd::int64 |
| Gets the total elapsed time measured by the current instance, in timer ticks. | |
| auto | is_running () const noexcept -> bool |
| Gets a value indicating whether the stopwatch timer is running. | |
Public Methods | |
| auto | reset () noexcept -> void |
| Stops time interval measurement and resets the elapsed time to zero. | |
| auto | restart () noexcept -> void |
| stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time. | |
| auto | start () noexcept -> void |
| Starts, or resumes, measuring elapsed time for an interval. | |
| auto | stop () noexcept -> void |
| Stops measuring elapsed time for an interval. | |
| static auto | start_new () noexcept -> xtd::diagnostics::stopwatch |
| Initializes a new xtd::diagnostics::stopwatch instance, sets the xtd::diagnostics::stopwatch::elapsed time property to zero, and starts measuring elapsed time. | |
Public Static Properties | |
| static auto | frequency () noexcept -> xtd::int64 |
| Gets the frequency of the timer as the number of nanoseconds per second. This field is read-only. | |
| static auto | is_high_resolution () noexcept -> bool |
| Indicates whether the timer is based on a high-resolution performance counter. This field is read-only. | |
Public Static Methods | |
| static auto | get_timestamp () noexcept -> std::chrono::nanoseconds |
| Gets the current number of nanoseconds in the timer mechanism. | |
| static auto | get_timestamp_milliseconds () noexcept -> xtd::int64 |
| Gets the current number of nanoseconds in the timer mechanism, in milliseconds. | |
| static auto | get_timestamp_nanoseconds () noexcept -> xtd::int64 |
| Gets the current number of nanoseconds in the timer mechanism, in nanoseconds. | |
| static auto | get_timestamp_ticks () noexcept -> xtd::int64 |
| Gets the current number of nanoseconds in the timer mechanism, in ticks. | |
Additional Inherited Members | |
| object ()=default | |
| Create a new instance of the ultimate base class object. | |
| virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. | |
| virtual xtd::size | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. | |
| virtual type_object | get_type () const noexcept |
| Gets the type of the current instance. | |
| template<class object_t> | |
| xtd::unique_ptr_object< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object. | |
| virtual xtd::string | to_string () const |
| Returns a xtd::string that represents the current object. | |
| template<class object_a_t, class object_b_t> | |
| static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal. | |
| template<class object_a_t, class object_b_t> | |
| static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are the same instance. | |
|
default |
Initializes a new instance of the xtd::diagnostics::stopwatch class.
|
nodiscardnoexcept |
Gets the total elapsed time measured by the current instance.
|
nodiscardnoexcept |
Gets the total elapsed time measured by the current instance, in milliseconds.
|
nodiscardnoexcept |
Gets the total elapsed time measured by the current instance, in nanoseconds.
|
nodiscardnoexcept |
Gets the total elapsed time measured by the current instance, in timer ticks.
|
nodiscardnoexcept |
Gets a value indicating whether the stopwatch timer is running.
true if the xtd::diagnostics::stopwatch instance is currently running and measuring elapsed time for an interval; otherwise, false.
|
staticnodiscardnoexcept |
Gets the frequency of the timer as the number of nanoseconds per second. This field is read-only.
|
staticnodiscardnoexcept |
Indicates whether the timer is based on a high-resolution performance counter. This field is read-only.
true if the timer is based on a high-resolution performance count; otherwise, false. true if the xtd::diagnostics::stopwatch timer is based on a high-resolution performance counter. Otherwise, xtd::diagnostics::stopwatch::is_high_resolution is false, which indicates that the xtd::diagnostics::stopwatch timer is based on the system timer. true.
|
noexcept |
Stops time interval measurement and resets the elapsed time to zero.
|
noexcept |
stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.
|
noexcept |
Starts, or resumes, measuring elapsed time for an interval.
|
staticnodiscardnoexcept |
Initializes a new xtd::diagnostics::stopwatch instance, sets the xtd::diagnostics::stopwatch::elapsed time property to zero, and starts measuring elapsed time.
|
noexcept |
Stops measuring elapsed time for an interval.
|
staticnodiscardnoexcept |
Gets the current number of nanoseconds in the timer mechanism.
|
staticnodiscardnoexcept |
Gets the current number of nanoseconds in the timer mechanism, in milliseconds.
|
staticnodiscardnoexcept |
Gets the current number of nanoseconds in the timer mechanism, in nanoseconds.
|
staticnodiscardnoexcept |
Gets the current number of nanoseconds in the timer mechanism, in ticks.