Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / RTCORBA / Activity / Task_Stats.inl
blobaaf0f485f463dc935fc0e708ea02bc1beceeb702
1 #include "ace/Log_Msg.h"
3 ACE_INLINE int
4 Task_Stats::sample (ACE_UINT64 inv_start_time, ACE_UINT64 inv_end_time)
6   if (this->samples_count_ >= this->max_samples_)
7   {
8     ACE_DEBUG ((LM_DEBUG, "Task_Stats::sample ret -1\n"));
9     return -1;
10    }
11   ACE_UINT64 inv_value, exec_value;
13   inv_value = inv_start_time - base_time_;
14   exec_value  = inv_end_time - inv_start_time;
16   this->time_inv_[this->samples_count_] = inv_value;
17   this->time_exec_[this->samples_count_] = exec_value;
19   this->samples_count_++;
21   if (this->samples_count_ == 1u)
22     {
23       this->exec_time_min_ = exec_value;
24       this->exec_time_min_at_ = this->samples_count_;
25       this->exec_time_max_ = exec_value;
26       this->exec_time_max_at_ = this->samples_count_;
27       this->sum_ = exec_value;
28       this->sum2_ = exec_value * exec_value;
29     }
30   else
31     {
32       if (this->exec_time_min_ > exec_value)
33         {
34           this->exec_time_min_ = exec_value;
35           this->exec_time_min_at_ = this->samples_count_;
36         }
37       if (this->exec_time_max_ < exec_value)
38         {
39           this->exec_time_max_ = exec_value;
40           this->exec_time_max_at_ = this->samples_count_;
41         }
43       this->sum_  += exec_value;
44       this->sum2_ += exec_value * exec_value;
45  }
46     return 0;