xtd - Reference Guide 0.2.0
stopwatch.h
Go to the documentation of this file.
1 #pragma once
5 #include <string>
6 #include "../object.h"
7 #include "../ticks.h"
8 
10 namespace xtd {
12  namespace diagnostics {
32  class core_export_ stopwatch : public xtd::object {
33  public:
35 
43  stopwatch() = default;
45 
47  stopwatch(const stopwatch&) = default;
48  stopwatch& operator=(const stopwatch&) = default;
50 
52 
56  static int64_t frequency();
57 
62  static bool is_high_resolution();
63 
74  std::chrono::nanoseconds elapsed() const;
75 
84  int64_t elapsed_milliseconds() const;
85 
91  int64_t elapsed_nanoseconds() const;
92 
101  int64_t elapsed_ticks() const;
102 
106  bool is_running() const;
108 
110 
114  static int64_t get_timestamp();
115 
118  void reset();
119 
122  void restart();
123 
131  void start();
132 
138  static stopwatch start_new();
139 
147  void stop();
149 
150  private:
151  explicit stopwatch(bool start);
152  bool running_ = false;
153  int64_t start_ = 0;
154  int64_t stop_ = 0;
155  };
156  }
157 }
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:32
Starting of a logical operation.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30