BlosSOM
Interactive dimensionality reduction on large datasets (EmbedSOM and FLOWER combined)
timer.h
Go to the documentation of this file.
1/* This file is part of BlosSOM.
2 *
3 * Copyright (C) 2021 Mirek Kratochvil
4 *
5 * BlosSOM is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free
7 * Software Foundation, either version 3 of the License, or (at your option)
8 * any later version.
9 *
10 * BlosSOM is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * BlosSOM. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef TIMER_H
20#define TIMER_H
21
22#include <chrono>
23
24/**
25 * @brief Handler for frametime computation.
26 *
27 */
28struct Timer
29{
30 using timepoint = std::chrono::time_point<std::chrono::steady_clock>;
31
32 /** Duration of the last frame (in seconds). */
33 float frametime;
34 /** Time of the last tick. */
36
37 /**
38 * @brief Calls @ref tick() and sets frametime to zero.
39 *
40 */
42 {
43 tick();
44 frametime = 0.0;
45 }
46
47 /**
48 * @brief Counts \p frametime and sets \p last_tick variable to current
49 * time.
50 *
51 */
52 void tick()
53 {
54 timepoint now = std::chrono::steady_clock::now();
55 frametime = std::chrono::duration<float>(now - last_tick).count();
56 last_tick = now;
57 }
58};
59
60#endif
Handler for frametime computation.
Definition: timer.h:29
timepoint last_tick
Time of the last tick.
Definition: timer.h:35
Timer()
Calls tick() and sets frametime to zero.
Definition: timer.h:41
void tick()
Counts frametime and sets last_tick variable to current time.
Definition: timer.h:52
std::chrono::time_point< std::chrono::steady_clock > timepoint
Definition: timer.h:30
float frametime
Duration of the last frame (in seconds).
Definition: timer.h:33