Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Sample_History.cpp
blob9f6abafac0435c4163a5b35b5fe60f484f83c80c
1 #include "ace/Sample_History.h"
3 #if !defined (__ACE_INLINE__)
4 #include "ace/Sample_History.inl"
5 #endif /* __ACE_INLINE__ */
7 #include "ace/Basic_Stats.h"
8 #include "ace/Log_Category.h"
9 #include "ace/OS_Memory.h"
11 #if defined (ACE_HAS_ALLOC_HOOKS)
12 # include "ace/Malloc_Base.h"
13 #endif /* ACE_HAS_ALLOC_HOOKS */
15 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 ACE_Sample_History::ACE_Sample_History (size_t max_samples)
18 : max_samples_ (max_samples)
19 , sample_count_ (0)
21 #if defined (ACE_HAS_ALLOC_HOOKS)
22 ACE_ALLOCATOR(this->samples_, static_cast<ACE_UINT64*>(ACE_Allocator::instance()->malloc(sizeof(ACE_UINT64) * this->max_samples_)));
23 #else
24 ACE_NEW(this->samples_, ACE_UINT64[this->max_samples_]);
25 #endif /* ACE_HAS_ALLOC_HOOKS */
28 ACE_Sample_History::~ACE_Sample_History ()
30 #if defined (ACE_HAS_ALLOC_HOOKS)
31 ACE_Allocator::instance()->free(this->samples_);
32 #else
33 delete[] this->samples_;
34 #endif /* ACE_HAS_ALLOC_HOOKS */
37 void
38 ACE_Sample_History::dump_samples (
39 const ACE_TCHAR *msg,
40 ACE_Sample_History::scale_factor_type scale_factor) const
42 #ifndef ACE_NLOGGING
43 for (size_t i = 0; i != this->sample_count_; ++i)
45 ACE_UINT64 const val = this->samples_[i] / scale_factor;
46 ACELIB_DEBUG ((LM_DEBUG,
47 ACE_TEXT ("%s: ")
48 ACE_SIZE_T_FORMAT_SPECIFIER
49 ACE_TEXT ("\t%Q\n"),
50 msg,
52 val));
54 #else
55 ACE_UNUSED_ARG (msg);
56 ACE_UNUSED_ARG (scale_factor);
57 #endif /* ACE_NLOGGING */
60 void
61 ACE_Sample_History::collect_basic_stats (ACE_Basic_Stats &stats) const
63 for (size_t i = 0; i != this->sample_count_; ++i)
65 stats.sample (this->samples_[i]);
69 ACE_END_VERSIONED_NAMESPACE_DECL