OTB  9.0.0
Orfeo Toolbox
otbStopwatch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbStopwatch_h
22 #define otbStopwatch_h
23 
24 #include <cstdint>
25 #include <string>
26 #include <iosfwd>
27 
28 #include "OTBCommonExport.h"
29 
30 namespace otb
31 {
32 
41 class OTBCommon_EXPORT Stopwatch final
42 {
43 public:
45  typedef Stopwatch Self;
46 
48  typedef uint64_t DurationType;
49 
51  Stopwatch();
52 
54  void Start();
55 
57  void Stop();
58 
60  void Reset();
61 
63  void Restart();
64 
66  DurationType GetElapsedMilliseconds() const;
67 
70  void GetElapsedHumanReadableTime(std::ostream& oss) const;
71 
73  std::string GetElapsedHumanReadableTime() const;
74 
76  bool IsRunning() const;
77 
79  static Stopwatch StartNew();
80 
81 private:
82  typedef uint64_t TimepointType;
83 
84  TimepointType GetTimestamp() const;
85  DurationType GetRunningElapsedTime() const;
86 
90 };
91 
92 } // namespace otb
93 
94 #endif
otb::Stopwatch::DurationType
uint64_t DurationType
Definition: otbStopwatch.h:48
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Stopwatch::TimepointType
uint64_t TimepointType
Definition: otbStopwatch.h:82
otb::Stopwatch
Stopwatch timer.
Definition: otbStopwatch.h:41
otb::Stopwatch::m_IsRunning
bool m_IsRunning
Definition: otbStopwatch.h:89
otb::Stopwatch::m_ElapsedMilliseconds
DurationType m_ElapsedMilliseconds
Definition: otbStopwatch.h:88
otb::Stopwatch::Self
Stopwatch Self
Definition: otbStopwatch.h:45
otb::Stopwatch::m_StartTime
TimepointType m_StartTime
Definition: otbStopwatch.h:87