Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

balm::StopwatchScopedGuard Class Reference

#include <balm_stopwatchscopedguard.h>

List of all members.

Public Types

enum  Units {
  k_NANOSECONDS = 1000000000, k_MICROSECONDS = 1000000, k_MILLISECONDS = 1000, k_SECONDS = 1,
  BAEM_NANOSECONDS = k_NANOSECONDS, BAEM_MICROSECONDS = k_MICROSECONDS, BAEM_MILLISECONDS = k_MILLISECONDS, BAEM_SECONDS = k_SECONDS,
  NANOSECONDS = k_NANOSECONDS, MICROSECONDS = k_MICROSECONDS, MILLISECONDS = k_MILLISECONDS, SECONDS = k_SECONDS
}
 

An enumeration of supported time units.

More...

Public Member Functions

 StopwatchScopedGuard (Metric *metric, Units timeUnits=k_SECONDS)
 StopwatchScopedGuard (Collector *collector, Units timeUnits=k_SECONDS)
 StopwatchScopedGuard (const MetricId &metricId, MetricsManager *manager=0)
 StopwatchScopedGuard (const MetricId &metricId, Units timeUnits, MetricsManager *manager=0)
 StopwatchScopedGuard (const char *category, const char *name, MetricsManager *manager=0)
 StopwatchScopedGuard (const char *category, const char *name, Units timeUnits, MetricsManager *manager=0)
 ~StopwatchScopedGuard ()
bool isActive () const

Detailed Description

This class provides a mechanism for recording, to a metric, the elapsed time from the construction of an instance of the guard until that instance goes out of scope (and is destroyed). The constructor of this class takes an optional argument indicating the time units in which to report the elapsed time; by default a guard will report time in seconds. The supplied time units determine the scale of the double value reported by this guard, but does not affect the precision of the elapsed time measurement. Each instance of this class delegates to a Collector for the metric. This Collector is initialized on construction based on the constructor arguments. If this scoped guard is not initialized with an active metric, or if the supplied metric becomes inactive before the scoped guard is destroyed, then isActive() will return false and no metric values will be recorded. Note that if the metric supplied at construction is not active when the scoped guard is constructed, the scoped guard will not become active or record metric values regardless of the future state of that supplied metric.

See Component balm_stopwatchscopedguard


Member Enumeration Documentation

Enumerator:
k_NANOSECONDS 
k_MICROSECONDS 
k_MILLISECONDS 
k_SECONDS 
BAEM_NANOSECONDS 
BAEM_MICROSECONDS 
BAEM_MILLISECONDS 
BAEM_SECONDS 
NANOSECONDS 
MICROSECONDS 
MILLISECONDS 
SECONDS 

Constructor & Destructor Documentation

balm::StopwatchScopedGuard::StopwatchScopedGuard ( Metric metric,
Units  timeUnits = k_SECONDS 
) [explicit]

Initialize this scoped guard to record elapsed time using the specified metric. Optionally specify the timeUnits in which to report elapsed time. If metric->isActive() is false, this object will also be inactive (i.e., will not record any values). The behavior is undefined unless metric is a valid address of a Metric object. Note that timeUnits indicates the scale of the double value reported by this guard, but does not affect the precision of the elapsed time measurement.

balm::StopwatchScopedGuard::StopwatchScopedGuard ( Collector collector,
Units  timeUnits = k_SECONDS 
) [explicit]

Initialize this scoped guard to record elapsed time using the specified collector. Optionally specify the timeUnits in which to report elapsed time. If collector is 0 or collector->category().enabled() == false, this object will be inactive (i.e., will not record any values). The behavior is undefined unless collector == 0 || collector->metricId().isValid(). Note that timeUnits indicates the scale of the double value reported by this guard, but does not affect the precision of the elapsed time measurement.

balm::StopwatchScopedGuard::StopwatchScopedGuard ( const MetricId metricId,
MetricsManager manager = 0 
)
balm::StopwatchScopedGuard::StopwatchScopedGuard ( const MetricId metricId,
Units  timeUnits,
MetricsManager manager = 0 
)

Initialize this scoped guard to record an elapsed time to the specified metricId from the optionally specified manager. Optionally specify the timeUnits in which to report elapsed time. If timeUnits is not provided, the elapsed time will be reported in seconds. If manager is 0, the DefaultMetricsManager singleton instance is used. If no manager is supplied and the default instance has not been created, this object will be inactive (i.e., it will not record any values); similarly, if the metric's associated category is disabled (i.e., metricId.category()->enabled() is false), then this object will be inactive. The behavior is undefined unless unless metricId is a valid id returned by the MetricRepository object owned by the indicated metrics manager. Note that timeUnits indicates the scale of the double value reported by this guard, but does not affect the precision of the elapsed time measurement.

balm::StopwatchScopedGuard::StopwatchScopedGuard ( const char *  category,
const char *  name,
MetricsManager manager = 0 
)
balm::StopwatchScopedGuard::StopwatchScopedGuard ( const char *  category,
const char *  name,
Units  timeUnits,
MetricsManager manager = 0 
)

Initialize this scoped guard to record an elapsed time to the metric, identified by the specified category and name, from the optionally specified manager. Optionally specify the timeUnits in which to report elapsed time. If timeUnits is not provided, the elapsed time will be reported in seconds. If manager is 0, use the DefaultMetricsManager instance. If no manager is supplied, and the default instance has not been created, this object will be inactive (i.e., it will not record any values); similarly, if the identified category is disabled, then this object will be inactive. The behavior is undefined unless category and name are null-terminated. Note that timeUnits indicates the scale of the double value reported by this guard, but does not affect the precision of the elapsed time measurement.

balm::StopwatchScopedGuard::~StopwatchScopedGuard (  ) 

Destroy this scoped guard and, if the scoped guard is active, record the accumulated elapsed time from its creation..


Member Function Documentation

bool balm::StopwatchScopedGuard::isActive (  )  const

Return true if this scoped guard will actively record metrics, and false otherwise. If the returned value is false the destructor will not record a value to the metric. A scoped guard will be inactive if either (1) it was not initialized with a valid metric, (2) the metric it was initialized with was not active at the time of construction, or (3) the metric supplied at construction is currently inactive, meaning the category of metrics this metric belongs to has been disabled since this object's construction (see the MetricsManager method setCategoryEnabled).


The documentation for this class was generated from the following file: