Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / RTCORBA / Activity / Task_Stats.h
blob235a40dc7c9b0524c68a0f230142e0a7e2216a7f
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file Task_Stats.h
6 * Utility Stats class that maintains the readings.
8 * @author Pradeep Gore <pradeep@cs.wustl.edu>
9 */
10 //=============================================================================
11 #ifndef TASK_STATS_H
12 #define TASK_STATS_H
14 #include "ace/OS_NS_time.h"
15 #include "ace/Singleton.h"
16 #include "tao/orbconf.h"
17 #include "tao/debug.h"
18 #include "ace/High_Res_Timer.h"
20 /**
21 * @class Base_Time
23 * @brief maintains readings recorded by tasks.
25 class Base_Time
27 public:
28 Base_Time (void);
29 ACE_hrtime_t base_time_;
32 typedef ACE_Singleton<Base_Time, TAO_SYNCH_MUTEX> BASE_TIME;
34 /**
35 * @class Task_Stats
37 * @brief maintains readings recorded by tasks.
39 class Task_Stats
41 public:
42 /// Constructor
43 Task_Stats (size_t max_samples);
45 /// Destructor
46 ~Task_Stats (void);
48 /// Init
49 int init (void);
51 /// Set the base time value.
52 void base_time (ACE_hrtime_t time);
54 /// Set the end time value.
55 void end_time (ACE_hrtime_t time);
57 /// Record a sample
58 int sample (ACE_UINT64 inv_start_time, ACE_UINT64 inv_end_time);
60 void dump_samples (const ACE_TCHAR *file_name, const ACE_TCHAR *msg,
61 ACE_High_Res_Timer::global_scale_factor_type scale_factor);
62 protected:
63 void dump_latency_stats (ACE_TCHAR *out_msg,
64 ACE_High_Res_Timer::global_scale_factor_type sf);
66 /// Base and end times
67 ACE_hrtime_t base_time_;
68 ACE_hrtime_t end_time_;
70 /// The maximum number of samples
71 ACE_UINT32 max_samples_;
73 /// The number of samples
74 ACE_UINT32 samples_count_;
76 /// The samples : the time of invocation. and the recorded exec. time .
77 ACE_UINT64 *time_inv_;
78 ACE_UINT64 *time_exec_;
80 /// The minimum value
81 ACE_UINT64 exec_time_min_;
83 /// The number of the sample that had the minimum value
84 ACE_UINT32 exec_time_min_at_;
86 /// The maximum value
87 ACE_UINT64 exec_time_max_;
89 /// The number of the sample that had the maximum value
90 ACE_UINT32 exec_time_max_at_;
92 /// The sum of all the values
93 ACE_UINT64 sum_;
95 /// The sum of the square of all the values
96 ACE_UINT64 sum2_;
99 #if defined (__ACE_INLINE__)
100 #include "Task_Stats.inl"
101 #endif /* __ACE_INLINE__ */
103 #endif /* TASK_STATS_H */