libosmscout  1.1.1
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 
30 namespace 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:
43  StopClock();
44 
45  StopClock(const StopClock&) = delete; // We do not want you to make copies of a stop clock
46  StopClock(StopClock&&) = default; // moves are fine
47 
48  StopClock& operator=(const StopClock&) = delete;
49  StopClock& operator=(StopClock&&) = default;
50 
51  void Stop();
52 
53  double GetMilliseconds() const;
54  std::chrono::steady_clock::duration GetDuration() const;
55 
56  bool IsSignificant() const;
57 
58  std::string ResultString() const;
59 
60  friend OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClock& clock);
61  };
62 
63  extern OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClock& clock);
64 
69  class OSMSCOUT_API StopClockNano CLASS_FINAL
70  {
71  private:
72  std::chrono::high_resolution_clock::time_point start;
73  std::chrono::high_resolution_clock::time_point stop;
74 
75  private:
76  // We do not want you to make copies of a stop clock
77  StopClockNano(const StopClockNano& other);
78 
79  public:
80  StopClockNano();
81 
82  void Stop();
83 
84  double GetNanoseconds() const;
85 
86  std::string ResultString() const;
87 
88  friend OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClockNano& clock);
89  };
90 
91  extern OSMSCOUT_API std::ostream& operator<<(std::ostream& stream, const StopClockNano& clock);
92 
93 }
94 
95 #endif
std::ostream & operator<<(std::ostream &stream, const DBId &o)
Definition: DBFileOffset.h:80
Definition: Area.h:38
#define CLASS_FINAL
Definition: Compiler.h:26
#define OSMSCOUT_API
Definition: CoreImportExport.h:45