summaryrefslogtreecommitdiff
path: root/TAO/examples/RTCORBA/Activity/Task_Stats.inl
blob: 78ce13d05bc0dc30a89a3c908343ffc6b15aefed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//$Id$

#include "ace/Log_Msg.h"

ACE_INLINE int
Task_Stats::sample (ACE_UINT64 inv_start_time, ACE_UINT64 inv_end_time)
{
  if (this->samples_count_ >= this->max_samples_)
  {
    ACE_DEBUG ((LM_DEBUG, "Task_Stats::sample ret -1\n"));
    return -1;
   }
  ACE_UINT64 inv_value, exec_value;

  inv_value = inv_start_time - base_time_;
  exec_value  = inv_end_time - inv_start_time;

  this->time_inv_[this->samples_count_] = inv_value;
  this->time_exec_[this->samples_count_] = exec_value;

  this->samples_count_++;

  if (this->samples_count_ == 1u)
    {
      this->exec_time_min_ = exec_value;
      this->exec_time_min_at_ = this->samples_count_;
      this->exec_time_max_ = exec_value;
      this->exec_time_max_at_ = this->samples_count_;
      this->sum_ = exec_value;
#if defined ACE_LACKS_LONGLONG_T
      this->sum2_ = exec_value * ACE_U64_TO_U32 (exec_value);
#else  /* ! ACE_LACKS_LONGLONG_T */
      this->sum2_ = exec_value * exec_value;
#endif /* ! ACE_LACKS_LONGLONG_T */
    }
  else
    {
      if (this->exec_time_min_ > exec_value)
        {
          this->exec_time_min_ = exec_value;
          this->exec_time_min_at_ = this->samples_count_;
        }
      if (this->exec_time_max_ < exec_value)
        {
          this->exec_time_max_ = exec_value;
          this->exec_time_max_at_ = this->samples_count_;
        }

      this->sum_  += exec_value;
#if defined ACE_LACKS_LONGLONG_T
      this->sum2_ += exec_value * ACE_U64_TO_U32 (exec_value);
#else  /* ! ACE_LACKS_LONGLONG_T */
      this->sum2_ += exec_value * exec_value;
#endif /* ! ACE_LACKS_LONGLONG_T */
 }
    return 0;
}