Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / examples / RTScheduling / Task_Stats.h
bloba99faeeeaa81870136921320d206e6176095ac0f
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 "rtschedtestlib_export.h"
16 #include "tao/orbconf.h"
17 #include "tao/debug.h"
19 #include "ace/OS_NS_time.h"
20 #include "ace/Singleton.h"
22 /**
23 * @class Base_Time
25 * @brief maintains readings recorded by tasks.
27 class RTSCHEDTESTLIB_Export Base_Time
29 public:
30 Base_Time ();
31 ACE_hrtime_t base_time_;
34 typedef ACE_Singleton<Base_Time, TAO_SYNCH_MUTEX> BASE_TIME;
36 /**
37 * @class Task_Stats
39 * @brief maintains readings recorded by tasks.
41 class RTSCHEDTESTLIB_Export Task_Stats
43 public:
44 /// Constructor
45 Task_Stats ();
47 /// Destructor
48 ~Task_Stats ();
50 /// Init
51 int init (size_t max_samples);
53 /// Set the base time value.
54 void base_time (ACE_hrtime_t time);
56 /// Set the end time value.
57 void end_time (ACE_hrtime_t time);
59 /// Record a sample
60 int sample (time_t thr_run_time, int thr_count);
62 void dump_samples (const ACE_TCHAR *file_name, const ACE_TCHAR *msg);
63 protected:
64 void dump_latency_stats (ACE_TCHAR *out_msg, ACE_UINT32 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 execution. and the recorded exec. time .
77 time_t *thr_run_time_;
78 int *thr_count_;
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 typedef ACE_Singleton<Task_Stats, TAO_SYNCH_MUTEX> TASK_STATS;
101 #if defined (__ACE_INLINE__)
102 #include "Task_Stats.inl"
103 #endif /* __ACE_INLINE__ */
105 #endif /* TASK_STATS_H */