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
)
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_
)));
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_
);
33 delete[] this->samples_
;
34 #endif /* ACE_HAS_ALLOC_HOOKS */
38 ACE_Sample_History::dump_samples (
40 ACE_Sample_History::scale_factor_type scale_factor
) const
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
,
48 ACE_SIZE_T_FORMAT_SPECIFIER
56 ACE_UNUSED_ARG (scale_factor
);
57 #endif /* ACE_NLOGGING */
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