libUTL++
OStimer.h
1 #pragma once
2 
4 
5 #include <libutl/Object.h>
6 
8 
9 #if UTL_HOST_OS == UTL_OS_MINGW
10 #include <libutl/win32api.h>
11 #else
12 #include <sys/times.h>
13 #endif
14 
16 
17 UTL_NS_BEGIN;
18 
20 
31 
33 class OStimer : public Object
34 {
39 
40 public:
42  void start();
44  void stop();
45 
47  double userTime();
49  double systemTime();
51  double totalTime();
52 
53 #if UTL_HOST_OS == UTL_OS_MINGW
54 private:
55  inline static double intervalSeconds(FILETIME& lhs, FILETIME& rhs);
56  FILETIME _userStart, _userStop;
57  FILETIME _systemStart, _systemStop;
58 #else
59 public:
61  double childUserTime();
63  double childSystemTime();
65  double childTotalTime();
66 
67 private:
68  inline static double clocksToSeconds(clock_t clocks);
69  struct tms _tmsStart;
70  struct tms _tmsStop;
71 #endif
72 };
73 
75 
76 UTL_NS_END;
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
Definition: macros.h:532
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
Measure CPU time.
Definition: OStimer.h:33
#define UTL_CLASS_NO_SERIALIZE
Declare that a class cannot do serialize().
Definition: macros.h:384
#define UTL_CLASS_NO_COPY
Declare that a class cannot do copy().
Definition: macros.h:358
Root of UTL++ class hierarchy.
Definition: Object.h:52