HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Timer.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_TIMER_H
7 #define MATERIALX_TIMER_H
8 
9 /// @file
10 /// Support for event timing
11 
12 #include <MaterialXRender/Export.h>
13 
14 #include <chrono>
15 
17 
18 /// @class ScopedTimer
19 /// A class for scoped event timing
21 {
22  public:
23  using clock = std::chrono::high_resolution_clock;
24 
25  ScopedTimer(double* externalCounter = nullptr);
26  ~ScopedTimer();
27 
28  /// Return the elapsed time in seconds since our start time.
29  double elapsedTime();
30 
31  /// Activate the timer, and set our start time to the current moment.
32  void startTimer();
33 
34  /// Deactivate the timer, and add the elapsed time to our external counter.
35  void endTimer();
36 
37  protected:
38  bool _active;
40  std::chrono::time_point<clock> _startTime;
41 };
42 
44 
45 #endif
std::chrono::time_point< clock > _startTime
Definition: Timer.h:40
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
bool _active
Definition: Timer.h:38
std::chrono::high_resolution_clock clock
Definition: Timer.h:23
double * _externalCounter
Definition: Timer.h:39
#define MX_RENDER_API
Definition: Export.h:18
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26