API Guides > ConceptRT 3.x
RTTimeMeasurement.h
1 // //
3 // <copyright company="Objectis"> //
4 // //
5 // Copyright (c) 2013, All Right Reserved, http://www.objectis.ch/ //
6 // //
7 // This source is subject to the Objectis Permissive License. //
8 // Please see the License contract for more information. //
9 // All other rights reserved. //
10 // //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY //
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE //
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //
14 // PARTICULAR PURPOSE. //
15 // //
16 // </copyright> //
17 // //
19 
20 #ifndef __RT_TIME_MEASUREMENT_H_
21 #define __RT_TIME_MEASUREMENT_H_
22 
23 #include "RTTimeSpan.h"
24 #include "RTDynamicInvocation.h"
25 
26 namespace ConceptRT
27 {
32  {
33  RT_DYNAMIC_CAST_0(UpTimer)
34  public:
35 
38  UpTimer(bool started = false);
39 
41  void Resume();
42 
44  void Suspend();
45 
48  bool IsResumed() const;
49 
51  void Clear();
52 
55  TimeSpan GetTime() const;
56  private:
57  TimeStamp _startTime;
58  TimeStamp _currentValue;
59  bool _stopped;
60  };
61 
66  {
67  RT_DYNAMIC_CAST_0(DownTimer)
68  public:
69 
72  DownTimer(TimeSpan duration = TimeZero);
73 
77  void SetTime(TimeSpan duration);
78 
80  void Clear();
81 
84  TimeSpan GetTime() const;
85 
88  bool GetElapsed() const;
89  private:
90  TimeStamp _startTime;
91  TimeSpan _timer;
92  };
93 
99  {
100  RT_DYNAMIC_CAST_1(TimeMeasurement, IInvocable)
101 
102 
105  PROPERTY_GET_PROTECTED_SET(TimeSpan, MinTime)
107  PROPERTY_GET_PROTECTED_SET(TimeSpan, AverageTime)
109  PROPERTY_GET_PROTECTED_SET(TimeSpan, LastTime)
112 
113  public:
115  TimeMeasurement();
116 
118  void Start();
120  void Stop();
122  void Reset();
123 
124  void Invoke(const DynamicInvocationRequest & request,
125  DynamicInvocationResult & result);
126 
127  private:
128  void InternalInvoke(const DynamicInvocationRequest & request,
129  DynamicInvocationResult & result);
130  double _averageTime;
131  UpTimer _timer;
132  };
133 }
134 
135 #endif
Dynamic invocation request.
Definition: RTDynamicInvocation.h:366
#define CONCEPTRT_API
ConceptRT export symbols for dynamic library exportation and importation.
Definition: RTDefinesUtils.h:70
Time down counter until TimeZero is reached
Definition: RTTimeMeasurement.h:65
Int64 TimeStamp
Type for 64 bits timestamp, in 100 ns unit.
Definition: RTTypesConcept.h:135
long Int32
Type for 32 bits signed integers.
Definition: RTTypesConcept.h:87
Time unit. Resolution is 100 ns.
Definition: RTTimeSpan.h:30
Dynamic invocation result.
Definition: RTDynamicInvocation.h:446
Helper to measure a process time.
Definition: RTTimeMeasurement.h:98
Invocable interface.
Definition: RTDynamicInvocation.h:349
#define PROPERTY_GET_PROTECTED_SET(type, name)
Helper to declare a property.
Definition: RTDefinesUtils.h:109
Time up counter (Chronometer)
Definition: RTTimeMeasurement.h:31
const TimeSpan TimeZero
The time zero
Library conceptRT namespace. Don't forget to use.