Quick Links: |
#include <balb_performancemonitor.h>
Provides a mechanism to collect performance statistics for an arbitrary number of processes running on the local machine.
See Component balb_performancemonitor
Enumerates the set of performance measures this class is capable of monitoring.
balb::PerformanceMonitor::PerformanceMonitor | ( | bslma::Allocator * | basicAllocator = 0 |
) | [explicit] |
Create an instance of this class to collect performance statistics on demand (via the collect
method). Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used.
balb::PerformanceMonitor::PerformanceMonitor | ( | bdlmt::TimerEventScheduler * | scheduler, | |
double | interval, | |||
bslma::Allocator * | basicAllocator = 0 | |||
) |
Create an instance of this class that uses the specified scheduler
to automatically collect performance statistics every specified interval
(specified in seconds). Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Note that a non-positive interval
value indicates that performance statistics should not be automatically collected--in this case the user is responsible for manually calling the collect
function.
balb::PerformanceMonitor::~PerformanceMonitor | ( | ) |
Destroy this object.
balb::PerformanceMonitor::BSLMF_NESTED_TRAIT_DECLARATION | ( | PerformanceMonitor | , | |
bslma::UsesBslmaAllocator | ||||
) |
int balb::PerformanceMonitor::registerPid | ( | int | pid, | |
const bsl::string & | description | |||
) |
Register the specified process pid
having the specified user-defined description
with this performance monitor. After registration, performance statistics will be collected for the pid
upon invocation of the collect
function. Note that a pid
value of zero is interpreted as the pid
of the current process. Return 0 on success or a non-zero value otherwise.
int balb::PerformanceMonitor::unregisterPid | ( | int | pid | ) |
Unregister the specified process pid
from the performance monitor. After unregistration, to statistics for the pid
will be no longer be available unless the pid
is re-registered with the performance monitor through calling registerPid
. Note that a pid
value of zero is interpreted as the pid
of the current process. Return 0 on success or a non-zero value otherwise.
void balb::PerformanceMonitor::setCollectionInterval | ( | double | interval | ) |
Set the specified time interval
, in seconds, after which statistics for each registered pid are automatically collected. The behavior is undefined unless a scheduler was supplied at the construction of this performance monitor. Note that a non-positive interval
value indicates that performance statistics should not be automatically collected--in this case the user is responsible for manually calling the collect
function.
void balb::PerformanceMonitor::collect | ( | ) |
Collect performance statistics for each registered pid.
void balb::PerformanceMonitor::resetStatistics | ( | ) |
Reset the collected min, max, and average values collected for each measure for each monitored process.
ConstIterator balb::PerformanceMonitor::begin | ( | ) | const |
Return an iterator positioned at the first set of collected performance statistics.
ConstIterator balb::PerformanceMonitor::end | ( | ) | const |
Return an iterator that represents the end of the sequence of sets of collected performance statistics.
ConstIterator balb::PerformanceMonitor::find | ( | int | pid | ) | const |
Return the iterator pointing to the set of collected performance statistics for the specified pid
if pid
has been registered with this performance monitor through the registerPid
function, otherwise return end()
.
int balb::PerformanceMonitor::numRegisteredPids | ( | ) | const |
Return the number of processes registered for statistics collection.
friend class Statistics [friend] |
friend class ConstIterator [friend] |