Skip to content

Commit

Permalink
feat: remove m timeit noise in callback
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jul 28, 2024
1 parent ae7f5a5 commit 911c2e6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions utils/timeit/timeit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type Timer struct {
msg string
ops []typelog.LogType
timeStarted time.Time

ResultErr error
}

type TimeOption func(m *Timer)
Expand Down Expand Up @@ -49,17 +47,17 @@ func (m *Timer) Close() {
utils_logus.Log.Debug(fmt.Sprintf("time_measure %v | %s", time.Since(m.timeStarted), m.msg), m.ops...)
}

func NewTimerF(callback func(m *Timer), opts ...TimeOption) *Timer {
func NewTimerF(callback func(), opts ...TimeOption) *Timer {
m := NewTimerMain(opts...)
defer m.Close()
callback(m)
callback()
return m
}

func NewTimerMF(msg string, callback func(m *Timer), opts ...TimeOption) *Timer {
func NewTimerMF(msg string, callback func(), opts ...TimeOption) *Timer {
return NewTimerF(callback, append([]TimeOption{WithMsg(msg)}, opts...)...)
}

func NewTimerMFL(msg string, callback func(m *Timer), opts ...typelog.LogType) *Timer {
func NewTimerMFL(msg string, callback func(), opts ...typelog.LogType) *Timer {
return NewTimerMF(msg, callback, WithLogs(opts...))
}

0 comments on commit 911c2e6

Please sign in to comment.