VTE cleanup related to GTK 3.24 requirement
[geany-mirror.git] / scintilla / src / ElapsedPeriod.h
blob36f03e162451c909a11570ef1769dbc098441aa2
1 // Scintilla source code edit control
2 /** @file ElapsedPeriod.h
3 ** Encapsulate C++ <chrono> to simplify use.
4 **/
5 // Copyright 2018 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #ifndef ELAPSEDPERIOD_H
9 #define ELAPSEDPERIOD_H
11 namespace Scintilla::Internal {
13 // Simplified access to high precision timing.
14 class ElapsedPeriod {
15 using ElapsedClock = std::chrono::steady_clock;
16 ElapsedClock::time_point tp;
17 public:
18 /// Capture the moment
19 ElapsedPeriod() noexcept : tp(ElapsedClock::now()) {
21 /// Return duration as floating point seconds
22 double Duration(bool reset=false) noexcept {
23 const ElapsedClock::time_point tpNow = ElapsedClock::now();
24 const std::chrono::duration<double> duration =
25 std::chrono::duration_cast<std::chrono::duration<double>>(tpNow - tp);
26 if (reset) {
27 tp = tpNow;
29 return duration.count();
35 #endif