diff options
Diffstat (limited to 'ace/Stats.cpp')
-rw-r--r-- | ace/Stats.cpp | 221 |
1 files changed, 3 insertions, 218 deletions
diff --git a/ace/Stats.cpp b/ace/Stats.cpp index 45b7eb8258b..fbd5f7f18c8 100644 --- a/ace/Stats.cpp +++ b/ace/Stats.cpp @@ -153,7 +153,8 @@ ACE_Stats::std_dev (ACE_Stats_Value &std_dev, // works with the Diab compiler the way it is! // // Square using 64-bit arithmetic. - sum_of_squares += difference * ACE_U64_TO_U32 (difference); + sum_of_squares += difference * + ACE_U64_TO_U32 (difference); i.advance (); if (sum_of_squares < original_sum_of_squares) @@ -272,7 +273,7 @@ ACE_Stats::print_summary (const u_int precision, #if !defined (ACE_HAS_WINCE) ACE_OS::fprintf (file, ASYS_TEXT ("ACE_Stats::print_summary: OVERFLOW: %s\n"), - ASYS_WIDE_STRING (strerror (overflow_))); + ASYS_TEXT (strerror (overflow_))); #else // WinCE doesn't have strerror ;( ACE_OS::fprintf (file, @@ -419,222 +420,6 @@ ACE_Stats::square_root (const ACE_UINT64 n, } } -// **************************************************************** - -ACE_Throughput_Stats::ACE_Throughput_Stats (void) - : samples_count_ (0), - latency_min_ (0), - latency_max_ (0), - latency_sum_ (0), - latency_sum2_ (0), - throughput_last_ (0), - throughput_sum_x_ (0), - throughput_sum_x2_ (0), - throughput_sum_y_ (0), - throughput_sum_y2_ (0), - throughput_sum_xy_ (0) -{ -} - -void -ACE_Throughput_Stats::sample (ACE_UINT64 throughput, - ACE_UINT64 latency) -{ - ++this->samples_count_; - - if (this->samples_count_ == 1) - { - this->latency_min_ = latency; - this->latency_max_ = latency; - this->latency_sum_ = latency; -#if defined ACE_LACKS_LONGLONG_T - this->latency_sum2_ = latency * ACE_U64_TO_U32 (latency); -#else /* ! ACE_LACKS_LONGLONG_T */ - this->latency_sum2_ = latency * latency; -#endif /* ! ACE_LACKS_LONGLONG_T */ - - this->throughput_last_ = throughput; -#if 0 - this->throughput_sum_y_ = this->samples_count_; - this->throughput_sum_y2_ = this->samples_count_ * this->samples_count_; - this->throughput_sum_x_ = throughput; - this->throughput_sum_x2_ = throughput * throughput; - this->throughput_sum_xy_ = throughput * this->samples_count_; - - printf ("%f %qu\n", throughput / 400000000.0, this->samples_count_); -#endif /* 0 */ - } - else - { - if (this->latency_min_ > latency) - this->latency_min_ = latency; - if (this->latency_max_ < latency) - this->latency_max_ = latency; - - this->latency_sum_ += latency; -#if defined ACE_LACKS_LONGLONG_T - this->latency_sum2_ += latency * ACE_U64_TO_U32 (latency); -#else /* ! ACE_LACKS_LONGLONG_T */ - this->latency_sum2_ += latency * latency; -#endif /* ! ACE_LACKS_LONGLONG_T */ - - this->throughput_last_ = throughput; - -#if 0 - this->throughput_sum_y_ += this->samples_count_; - this->throughput_sum_y2_ += this->samples_count_ * this->samples_count_; - this->throughput_sum_x_ += throughput; - this->throughput_sum_x2_ += throughput * throughput; - this->throughput_sum_xy_ += throughput * this->samples_count_; - - printf ("%f %qu\n", throughput / 400000000.0, this->samples_count_); -#endif /* 0 */ - } -} - -void -ACE_Throughput_Stats::accumulate (const ACE_Throughput_Stats &rhs) -{ - if (rhs.samples_count_ == 0) - return; - - if (this->samples_count_ == 0) - { - this->samples_count_ = rhs.samples_count_; - - this->latency_min_ = rhs.latency_min_; - this->latency_max_ = rhs.latency_max_; - this->latency_sum_ = rhs.latency_sum_; - this->latency_sum2_ = rhs.latency_sum2_; - - this->throughput_last_ = rhs.throughput_last_; -#if 0 - this->throughput_sum_x_ = rhs.throughput_sum_x_; - this->throughput_sum_x2_ = rhs.throughput_sum_x2_; - this->throughput_sum_y_ = rhs.throughput_sum_y_; - this->throughput_sum_y2_ = rhs.throughput_sum_y2_; - this->throughput_sum_xy_ = rhs.throughput_sum_xy_; -#endif /* 0 */ - - return; - } - - this->samples_count_ += rhs.samples_count_; - - if (this->latency_min_ > rhs.latency_min_) - this->latency_min_ = rhs.latency_min_; - if (this->latency_max_ < rhs.latency_max_) - this->latency_max_ = rhs.latency_max_; - - this->latency_sum_ += rhs.latency_sum_; - this->latency_sum2_ += rhs.latency_sum2_; - - if (this->throughput_last_ < rhs.throughput_last_) - this->throughput_last_ = rhs.throughput_last_; - -#if 0 - this->throughput_sum_x_ += rhs.throughput_sum_x_; - this->throughput_sum_x2_ += rhs.throughput_sum_x2_; - this->throughput_sum_y_ += rhs.throughput_sum_y_; - this->throughput_sum_y2_ += rhs.throughput_sum_y2_; - this->throughput_sum_xy_ += rhs.throughput_sum_xy_; -#endif /* 0 */ -} - -void -ACE_Throughput_Stats::dump_results (const ASYS_TCHAR* msg, - ACE_UINT32 sf) -{ - if (this->samples_count_ == 0) - { - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("%s : no data collected\n"))); - return; - } - - ACE_UINT64 latency_avg = this->latency_sum_ / -#if defined ACE_LACKS_LONGLONG_T - ACE_U64_TO_U32 (this->samples_count_); -#else /* ! ACE_LACKS_LONGLONG_T */ - this->samples_count_; -#endif /* ! ACE_LACKS_LONGLONG_T */ - ACE_UINT64 latency_dev = -#if defined ACE_LACKS_LONGLONG_T - ACE_static_cast (ACE_U_LongLong, - this->latency_sum2_ / ACE_U64_TO_U32(this->samples_count_)) - - latency_avg * ACE_U64_TO_U32(latency_avg); -#else /* ! ACE_LACKS_LONGLONG_T */ - this->latency_sum2_ / this->samples_count_ - latency_avg * latency_avg; -#endif /* ! ACE_LACKS_LONGLONG_T */ - - double l_min = ACE_CU64_TO_CU32 (this->latency_min_) / sf; - double l_max = ACE_CU64_TO_CU32 (this->latency_max_) / sf; - double l_avg = ACE_CU64_TO_CU32 (latency_avg) / sf; - double l_dev = ACE_CU64_TO_CU32 (latency_dev) / (sf * sf); - - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("%s latency: %.2f/%.2f/%.2f/%.2f (min/avg/max/var^2)\n"), - msg, l_min, l_avg, l_max, l_dev)); - - double seconds = -#if defined ACE_LACKS_LONGLONG_T - this->throughput_last_ / sf; -#else /* ! ACE_LACKS_LONGLONG_T */ - ACE_static_cast (double, - ACE_UINT64_DBLCAST_ADAPTER(this->throughput_last_ / sf)); -#endif /* ! ACE_LACKS_LONGLONG_T */ - seconds /= 1000000.0; - double t_avg = ACE_CU64_TO_CU32 (this->samples_count_) / seconds; - - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("%s throughput: %.2f (events/second)\n"), - msg, t_avg)); - -#if 0 - double t_sum_x = - ACE_CU64_TO_CU32 (this->throughput_sum_x_);// / sf); - //t_sum_x /= 1000000.0; - double t_sum_y = - ACE_CU64_TO_CU32 (this->throughput_sum_y_); - double t_sum_x2 = - ACE_CU64_TO_CU32 (this->throughput_sum_x2_);// / (sf*sf)); - //t_sum_x2 /= 1000000.0; - //t_sum_x2 /= 1000000.0; - double t_sum_y2 = - ACE_CU64_TO_CU32 (this->throughput_sum_y2_); - double t_sum_xy = - ACE_CU64_TO_CU32 (this->throughput_sum_xy_);// / sf); - //t_sum_xy /= 1000000.0; - double t_avgx = t_sum_x / this->samples_count_; - double t_avgy = t_sum_y / this->samples_count_; - - double t_a = - (this->samples_count_ * t_sum_xy - t_sum_x * t_sum_y) - / (this->samples_count_ * t_sum_x2 - t_sum_x * t_sum_x); - double t_b = (t_avgy - t_a * t_avgx); - - t_a *= 1000000.0; - - double d_r = - (t_sum_xy - t_avgx * t_sum_y - t_avgy * t_sum_x - + this->samples_count_ * t_avgx * t_avgy); - double n_r = - (t_sum_x2 - - this->samples_count_ * t_avgx * t_avgx) - * (t_sum_y2 - - this->samples_count_ * t_avgy * t_avgy); - double t_r = d_r * d_r / n_r; - - // ACE_DEBUG ((LM_DEBUG, - // "%s throughput: %.2f/%.2f/%.2f/%.6f/%.2f (avg/a/b/r/elapsed)\n", - // msg, t_avg, t_a, t_b, t_r, seconds)); - // ACE_DEBUG ((LM_DEBUG, - // "%s data: %.2f/%.2f/%.2f/%.6f/%.2f (x/x2/y/y2/xy)\n", - // msg, t_sum_x, t_sum_x2, t_sum_y, t_sum_y2, t_sum_xy)); -#endif -} - -// **************************************************************** - #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Node <ACE_INT32>; template class ACE_Unbounded_Queue <ACE_INT32>; |