Ice 3.7 C++11 API Reference
StopWatch.h
Go to the documentation of this file.
1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_UTIL_STOPWATCH_H
6 #define ICE_UTIL_STOPWATCH_H
7 
8 #include <IceUtil/Time.h>
9 
10 namespace IceUtilInternal
11 {
12 
13 class StopWatch
14 {
15 public:
16 
17  StopWatch() { }
18 
19  void start()
20  {
22  }
23 
24  IceUtil::Int64 stop()
25  {
26  assert(isStarted());
27  IceUtil::Int64 d = (IceUtil::Time::now(IceUtil::Time::Monotonic) - _s).toMicroSeconds();
28  _s = IceUtil::Time();
29  return d;
30  }
31 
32  bool isStarted() const
33  {
34  return _s != IceUtil::Time();
35  }
36 
37  IceUtil::Int64 delay()
38  {
39  return (IceUtil::Time::now(IceUtil::Time::Monotonic) - _s).toMicroSeconds();
40  }
41 
42 private:
43 
44  IceUtil::Time _s;
45 };
46 
47 } // End namespace IceUtilInternal
48 
49 #endif
IceUtil::Time::now
static Time now(Clock=Realtime)
IceUtil::Time::Monotonic
@ Monotonic
Definition: Time.h:27
IceUtil::Time
Definition: Time.h:18
Time.h
IceUtil::Int64
long long Int64
Definition: Config.h:342