Skip to content

Instantly share code, notes, and snippets.

@jostyee
Created June 8, 2016 06:00
Show Gist options
  • Save jostyee/27f7ca71ad69fc2f6536ba7a1d520403 to your computer and use it in GitHub Desktop.
Save jostyee/27f7ca71ad69fc2f6536ba7a1d520403 to your computer and use it in GitHub Desktop.
Computer the time duration a func consumed
func TimeCost(f func()) time.Duration {
start := time.Now()
f()
return time.Since(start)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment