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.
Declared in <balm_stopwatchscopedguard.h>
class StopwatchScopedGuard;
| Name | Description |
|---|---|
Units | Time units for reporting elapsed time. |
| Name | Description |
|---|---|
StopwatchScopedGuard [constructor] | Constructors |
~StopwatchScopedGuard [destructor] | Destroy this scoped guard and, if the scoped guard is active, record the accumulated elapsed time from its creation.. |
isActive | 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). |