Created
June 8, 2016 06:00
-
-
Save jostyee/27f7ca71ad69fc2f6536ba7a1d520403 to your computer and use it in GitHub Desktop.
Computer the time duration a func consumed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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