libosmscout 1.1.1
Loading...
Searching...
No Matches
StopClock.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_UTIL_STOPCLOCK_H
2#define OSMSCOUT_UTIL_STOPCLOCK_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2009 Tim Teulings
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library 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 GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
23#include <chrono>
24#include <string>
25
27
29
30namespace osmscout {
31
36 class OSMSCOUT_API StopClock CLASS_FINAL
37 {
38 private:
39 std::chrono::steady_clock::time_point start;
40 std::chrono::steady_clock::time_point stop;
41
42 public:
44 ~StopClock() = default;
45
46 StopClock(const StopClock&) = delete; // We do not want you to make copies of a stop clock
47 StopClock(StopClock&&) = default; // moves are fine
48
49 StopClock& operator=(const StopClock&) = delete;
51
52 void Stop();
53
54 double GetMilliseconds() const;
55 std::chrono::steady_clock::duration GetDuration() const;
56
57 bool IsSignificant() const;
58
59 std::string ResultString() const;
60
61 friend OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClock& stopClock);
62 };
63
64 extern OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClock& stopClock);
65
70 class OSMSCOUT_API StopClockNano CLASS_FINAL
71 {
72 private:
73 std::chrono::high_resolution_clock::time_point start;
74 std::chrono::high_resolution_clock::time_point stop;
75
76 public:
78 ~StopClockNano() = default;
79
80 StopClockNano(const StopClockNano& other) = delete;
81 StopClockNano(StopClockNano &&) = default; // moves are fine
82
85
86 void Stop();
87
88 double GetNanoseconds() const;
89
90 std::string ResultString() const;
91
92 friend OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClockNano& stopClock);
93 };
94
95 extern OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClockNano& stopClock);
96
97}
98
99#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition Area.h:88
StopClock(const StopClock &)=delete
StopClock & operator=(StopClock &&)=default
StopClock & operator=(const StopClock &)=delete
StopClockNano(const StopClockNano &other)=delete
StopClockNano(StopClockNano &&)=default
std::chrono::steady_clock::duration GetDuration() const
friend OSMSCOUT_API std::ostream & operator<<(std::ostream &stream, const StopClockNano &stopClock)
bool IsSignificant() const
StopClockNano & operator=(StopClockNano &&)=default
StopClock(StopClock &&)=default
double GetNanoseconds() const
double GetMilliseconds() const
StopClockNano & operator=(const StopClockNano &)=delete
friend OSMSCOUT_API std::ostream & operator<<(std::ostream &stream, const StopClock &stopClock)
std::string ResultString() const
Definition Area.h:39
std::ostream & operator<<(std::ostream &stream, const DBId &o)
Definition DBFileOffset.h:80