MaterialX 1.39.0
Loading...
Searching...
No Matches
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
11
13
14#include <chrono>
15
16MATERIALX_NAMESPACE_BEGIN
17
20class MX_RENDER_API ScopedTimer
21{
22 public:
23 using clock = std::chrono::high_resolution_clock;
24
25 ScopedTimer(double* externalCounter = nullptr);
27
29 double elapsedTime();
30
32 void startTimer();
33
35 void endTimer();
36
37 protected:
38 bool _active;
39 double* _externalCounter;
40 std::chrono::time_point<clock> _startTime;
41};
42
43MATERIALX_NAMESPACE_END
44
45#endif
Macros for declaring imported and exported symbols.
A class for scoped event timing.
Definition: Timer.h:21
void endTimer()
Deactivate the timer, and add the elapsed time to our external counter.
void startTimer()
Activate the timer, and set our start time to the current moment.
double elapsedTime()
Return the elapsed time in seconds since our start time.