Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
StopWatch.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Marc Sturm, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_SYSTEM_STOPWATCH_H
36 #define OPENMS_SYSTEM_STOPWATCH_H
37 
38 #include <OpenMS/config.h>
39 
40 #include <OpenMS/CONCEPT/Types.h>
42 
43 #ifdef OPENMS_HAS_SYS_TIME_H
44 #include <sys/time.h>
45 #endif
46 
47 #ifdef OPENMS_HAS_TIME_H
48 #include <ctime>
49 #endif
50 
51 namespace OpenMS
52 {
60  class OPENMS_DLLAPI StopWatch
61  {
62 public:
63 
67 
71  StopWatch();
72 
76  StopWatch(const StopWatch & stop_watch);
77 
81  virtual ~StopWatch();
82 
84 
87 
92  void clear();
93 
99  bool start();
100 
106  bool stop();
107 
112  void reset();
113 
115 
119 
123  double getClockTime() const;
124 
128  double getUserTime() const;
129 
133  double getSystemTime() const;
134 
139  double getCPUTime() const;
140 
142 
146 
152  StopWatch & operator=(const StopWatch & stop_watch);
153 
155 
159 
163  bool isRunning() const;
164 
172  bool operator==(const StopWatch & stop_watch) const;
173 
181  bool operator!=(const StopWatch & stop_watch) const;
182 
189  bool operator<(const StopWatch & stop_watch) const;
190 
197  bool operator<=(const StopWatch & stop_watch) const;
198 
205  bool operator>=(const StopWatch & stop_watch) const;
206 
213  bool operator>(const StopWatch & stop_watch) const;
214 
216 
224  String toString() const;
225 
229  static String toString(double time);
230 
231 private:
232 
233  static PointerSizeInt cpu_speed_;
234 
235 #ifdef OPENMS_WINDOWSPLATFORM
236  static PointerSizeInt clock_speed_;
237  typedef OPENMS_UINT64_TYPE TimeType; // do not use clock_t on Windows, since its not big enough for larger time intervals
238 #else
239  typedef clock_t TimeType;
240 #endif
241 
242  // state of stop watch, either true(on) or false(off)
244 
245  // clock seconds value when the stop watch was last started
246  PointerSizeInt start_secs_;
247 
248  // clock useconds value when the stop watch was last started
249  PointerSizeInt start_usecs_;
250 
251  // user time when the stop watch was last started
253 
254  // system time when the stop watch was last started
256 
257  // current accumulated clock seconds
258  PointerSizeInt current_secs_;
259 
260  // current accumulated clock useconds
261  PointerSizeInt current_usecs_;
262 
263  // current accumulated user time
265 
266  // current accumulated user time
268  };
269 
270 }
271 
272 
273 
274 #endif // OPENMS_SYSTEM_STOPWATCH_H
A more convenient string class.
Definition: String.h:57
StopWatch Class.
Definition: StopWatch.h:60
PointerSizeInt current_usecs_
Definition: StopWatch.h:261
TimeType current_system_time_
Definition: StopWatch.h:267
TimeType current_user_time_
Definition: StopWatch.h:264
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
PointerSizeInt start_usecs_
Definition: StopWatch.h:249
TimeType start_system_time_
Definition: StopWatch.h:255
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
PointerSizeInt start_secs_
Definition: StopWatch.h:246
static PointerSizeInt cpu_speed_
Definition: StopWatch.h:233
bool is_running_
Definition: StopWatch.h:243
PointerSizeInt current_secs_
Definition: StopWatch.h:258
TimeType start_user_time_
Definition: StopWatch.h:252
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
String toString(T i)
toString functions (single argument)
Definition: StringUtils.h:69
clock_t TimeType
Definition: StopWatch.h:239

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:04 using doxygen 1.8.13