[skip ci]Fix golint warnings in timerecord (#9104)

Signed-off-by: Xiangyu Wang <xiangyu.wang@zilliz.com>
pull/9107/head
Xiangyu Wang 2021-10-03 00:53:55 +08:00 committed by GitHub
parent 02b2f3c88b
commit 71b7e768e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import (
"github.com/milvus-io/milvus/internal/log" "github.com/milvus-io/milvus/internal/log"
) )
// TimeRecorder provides methods to record time duration
type TimeRecorder struct { type TimeRecorder struct {
header string header string
start time.Time start time.Time
@ -33,6 +34,7 @@ func NewTimeRecorder(header string) *TimeRecorder {
} }
} }
// RecordSpan return the duration from last record
func (tr *TimeRecorder) RecordSpan() time.Duration { func (tr *TimeRecorder) RecordSpan() time.Duration {
curr := time.Now() curr := time.Now()
span := curr.Sub(tr.last) span := curr.Sub(tr.last)
@ -40,6 +42,7 @@ func (tr *TimeRecorder) RecordSpan() time.Duration {
return span return span
} }
// ElapseSpan return the duration from the beginning
func (tr *TimeRecorder) ElapseSpan() time.Duration { func (tr *TimeRecorder) ElapseSpan() time.Duration {
curr := time.Now() curr := time.Now()
span := curr.Sub(tr.start) span := curr.Sub(tr.start)