The bliss C++ API 0.77 (Debian 0.77-3)
timer.hh
1#pragma once
2
3/*
4 Copyright (c) 2003-2021 Tommi Junttila
5 Released under the GNU Lesser General Public License version 3.
6
7 This file is part of bliss.
8
9 bliss is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, version 3 of the License.
12
13 bliss is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with bliss. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22
23#include <chrono>
24
25namespace bliss {
26
30class Timer
31{
32 std::chrono::high_resolution_clock::time_point start_time_;
33public:
38 reset();
39 }
40
44 void reset() {
45 start_time_ = std::chrono::high_resolution_clock::now();
46 }
47
52 double get_duration() const {
53 return std::chrono::duration_cast<std::chrono::duration<double> >(std::chrono::high_resolution_clock::now() - start_time_).count();
54 }
55};
56
57} // namespace bliss
A simple helper class for measuring elapsed time.
Definition: timer.hh:31
void reset()
Reset the timer.
Definition: timer.hh:44
Timer()
Create and start a new timer.
Definition: timer.hh:37
double get_duration() const
Get the time (in seconds) elapsed since the creation or the last reset() call of the timer.
Definition: timer.hh:52
Definition: abstractgraph.cc:35