[#BloombergLP-balm-StopwatchScopedGuard]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balm.adoc[balm]::StopwatchScopedGuard
:relfileprefix: ../../
:mrdocs:

This class provides a mechanism for recording, to a metric, the elapsed time from construction of a guard instance until that instance is destroyed&period;

== Synopsis

Declared in `&lt;balm&lowbar;stopwatchscopedguard&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class StopwatchScopedGuard;
----

== Description

The constructor of this class takes an optional argument indicating the time units in which to report the elapsed time&semi; by default a guard will report time in seconds&period; 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&period; Each instance of this class delegates to a `Collector` for the metric&period; This `Collector` is initialized on construction based on the constructor arguments&period; 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&period; 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&period;

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/StopwatchScopedGuard/Units.adoc[`Units`] 
| Time units for reporting elapsed time&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/StopwatchScopedGuard/2constructor-022.adoc[`StopwatchScopedGuard`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/balm/StopwatchScopedGuard/2destructor.adoc[`&#126;StopwatchScopedGuard`] [.small]#[destructor]#
| Destroy this scoped guard and, if the scoped guard is active, record the accumulated elapsed time from its creation&period;&period;
| xref:BloombergLP/balm/StopwatchScopedGuard/isActive.adoc[`isActive`] 
| Return `true` if this scoped guard will actively record metrics, and `false` otherwise&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
