KSeExpr
6.0.0.0
KSeExpr
Timer.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2020 L. E. Segovia <amy@amyspark.me>
2
// SPDX-License-Identifier: GPL-3.0-or-later
3
4
#include <cassert>
5
#include <chrono>
6
7
namespace
KSeExpr
8
{
9
class
Timer
10
{
11
using
Time
= std::time_t;
12
13
public
:
14
Timer
() =
default
;
15
void
start
()
16
{
17
started
=
true
;
18
startTime
= std::chrono::steady_clock::now();
19
}
20
21
void
stop
()
22
{
23
started
=
false
;
24
}
25
26
std::chrono::steady_clock::rep
elapsedTime
()
27
{
28
if
(!
started
)
start
();
29
stopTime
= std::chrono::steady_clock::now();
30
return
std::chrono::duration_cast<std::chrono::milliseconds>(
stopTime
-
startTime
).count();
31
}
32
33
private
:
34
std::chrono::steady_clock::time_point
startTime
,
stopTime
;
35
bool
started
{
false
};
36
};
37
38
}
// namespace KSeExpr
KSeExpr::Timer
Definition
Timer.h:10
KSeExpr::Timer::started
bool started
Definition
Timer.h:35
KSeExpr::Timer::start
void start()
Definition
Timer.h:15
KSeExpr::Timer::elapsedTime
std::chrono::steady_clock::rep elapsedTime()
Definition
Timer.h:26
KSeExpr::Timer::stopTime
std::chrono::steady_clock::time_point stopTime
Definition
Timer.h:34
KSeExpr::Timer::startTime
std::chrono::steady_clock::time_point startTime
Definition
Timer.h:34
KSeExpr::Timer::Timer
Timer()=default
KSeExpr::Timer::stop
void stop()
Definition
Timer.h:21
KSeExpr::Timer::Time
std::time_t Time
Definition
Timer.h:11
KSeExpr
Definition
Context.h:13
Generated by
1.9.8