File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,16 @@ func NewTimer(o Observer) *Timer {
3939
4040// ObserveDuration records the duration passed since the Timer was created with
4141// NewTimer. It calls the Observe method of the Observer provided during
42- // construction with the duration in seconds as an argument. ObserveDuration is
43- // usually called with a defer statement.
42+ // construction with the duration in seconds as an argument. The observed
43+ // duration is also returned. ObserveDuration is usually called with a defer
44+ // statement.
4445//
4546// Note that this method is only guaranteed to never observe negative durations
4647// if used with Go1.9+.
47- func (t * Timer ) ObserveDuration () {
48+ func (t * Timer ) ObserveDuration () time.Duration {
49+ d := time .Since (t .begin )
4850 if t .observer != nil {
49- t .observer .Observe (time . Since ( t . begin ) .Seconds ())
51+ t .observer .Observe (d .Seconds ())
5052 }
53+ return d
5154}
You can’t perform that action at this time.
0 commit comments