mCRL2
Loading...
Searching...
No Matches
stopwatch.h
Go to the documentation of this file.
1// Author(s): Maurice Laveaux
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9
10#ifndef MCRL2_UTILITIES_STOPWATCH_H_
11#define MCRL2_UTILITIES_STOPWATCH_H_
12
13#include <chrono>
14
17{
18public:
20 {
21 reset();
22 }
23
25 void reset()
26 {
27 m_timestamp = std::chrono::steady_clock::now();
28 }
29
31 long long time()
32 {
33 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - m_timestamp).count();
34 }
35
37 double seconds()
38 {
39 return std::chrono::duration<double>(std::chrono::steady_clock::now() - m_timestamp).count();
40 }
41
42private:
43 std::chrono::time_point<std::chrono::steady_clock> m_timestamp;
44};
45
46#endif // MCRL2_UTILITIES_STOPWATCH_H_
Implements a simple stopwatch that starts on construction.
Definition stopwatch.h:17
void reset()
Reset the stopwatch to count from this moment onwards.
Definition stopwatch.h:25
long long time()
Definition stopwatch.h:31
double seconds()
Definition stopwatch.h:37
std::chrono::time_point< std::chrono::steady_clock > m_timestamp
Definition stopwatch.h:43