github.com/go-board/x-go@v0.1.2-0.20220610024734-db1323f6cb15/xtime/duration.go (about)

     1  package xtime
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // MeasureDuration will measure duration of an operation.
     8  func MeasureDuration(fn func()) time.Duration {
     9  	now := time.Now()
    10  	fn()
    11  	return time.Since(now)
    12  }