CodeTimerEntry¶
CodeTimerEntry is the mutable record of one timer's running state: name, quantity, start/stop timestamps, longest/shortest/elapsed durations, and a history of captured CustomTimeSpan instances. Instances are held in CodeTimer's static timer dictionary.
Purpose¶
- Track the lifecycle (running/not running) and accumulated statistics of a single named or method-scoped timer.
Context¶
- Namespace:
SAIF.Framework.CodeTimer - Assembly/package:
SAIF.Framework.CodeTimer.dll
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| name | public string name |
The hierarchical key/name identifying this timer entry. |
| quantity | public int quantity |
Number of times this timer has been started; initialized to 1 on construction. |
| started | public DateTime started |
Timestamp when the entry was first created. |
| lastStarted | public DateTime lastStarted |
Timestamp of the most recent Start() call. |
| lastStopped | public DateTime lastStopped |
Timestamp of the most recent Stop() call. |
| longest | public double longest |
Longest single recorded span, in milliseconds. |
| shortest | public double shortest |
Shortest single recorded span, in milliseconds (-1 until a span is recorded). |
| elapsed | public double elapsed |
Cumulative elapsed time across all recorded spans, in milliseconds. |
| spans | public List<CustomTimeSpan> spans |
History of individual captured CustomTimeSpan instances for this entry. |
| CodeTimerEntry | public CodeTimerEntry(string name) |
Constructs a new entry, marking it started with quantity = 1. |
| IsRunning | public bool IsRunning() |
Returns whether the entry is currently in a running state. |
Inherited public members¶
Behavioral notes¶
Start()andStop()/Stop(bool isFinal)are declaredinternal, so timer lifecycle control is restricted to within theSAIF.Framework.CodeTimerassembly; onlyCodeTimer(in the same assembly) can start/stop an entry directly.- Calling
Start()while already running throwsApplicationException("StopWatch running")(see BR-001). - Calling
Stop(bool)while not running throwsApplicationException("StopWatch not running")(see BR-002). - On
Stop(bool isFinal), the entry computes the elapsed span sincelastStarted, adds it to cumulativeelapsed, updateslongest/shortest, and appends a newCustomTimeSpantospans. - A commented-out
Stopwatch swfield exists in source but is not active; timing is instead computed fromDateTimetimestamp differences*.
Constraints and usage notes¶
- Instances are only meaningfully constructed and mutated by
CodeTimer; external callers can read the public fields but cannot callStart()/Stop()directly since those members areinternal. shortestis-1until the firstStop()call completes, so callers should not treat-1as a valid duration.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
- SAIF.Framework.CodeTimer\SAIF.Framework.CodeTimer\CodeTimerEntry.cs