svMultiPhysics
Loading...
Searching...
No Matches
Timer.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef TIMER_H
5#define TIMER_H
6
7#include <chrono>
8
9/// @brief Keep track of time
10class Timer
11{
12 public:
13
14 double get_elapsed_time() const
15 {
16 return get_time() - current_time;
17 }
18
19 double get_time() const
20 {
21 const auto now = std::chrono::steady_clock::now();
22 return std::chrono::duration<double>(now.time_since_epoch()).count();
23 }
24
25 void set_time()
26 {
27 current_time = get_time();
28 }
29
30 double current_time{0.0};
31};
32
33#endif
Keep track of time.
Definition Timer.h:11