Skip to content

Commit

Permalink
return the duration of the span (#28)
Browse files Browse the repository at this point in the history
* return the duration of the span

* fix the interface
  • Loading branch information
btc authored Mar 20, 2018
1 parent 943f43e commit 35093b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ type Timer interface {
// return by calling Complete with golang's defer statement.
type Timespan interface {
// End the Timespan and flush it.
Complete()
Complete() time.Duration

// End the Timespan and flush it. Adds additional time.Duration to the measured time
CompleteWithDuration(time.Duration)
Expand Down Expand Up @@ -290,8 +290,10 @@ type timespan struct {
start time.Time
}

func (ts *timespan) Complete() {
ts.timer.time(time.Now().Sub(ts.start))
func (ts *timespan) Complete() time.Duration {
d := time.Now().Sub(ts.start)
ts.timer.time(d)
return d
}

func (ts *timespan) CompleteWithDuration(value time.Duration) {
Expand Down

0 comments on commit 35093b5

Please sign in to comment.