Created
August 16, 2017 03:15
-
-
Save bahaddinyasar/d7621aad1c041325a38a68cc611fe293 to your computer and use it in GitHub Desktop.
method execution time tracking in go
This file contains hidden or 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 timeTrack(start time.Time, name string) { | |
elapsed := time.Since(start) | |
log.Printf("%s took %s", name, elapsed) | |
} | |
func factorial(n *big.Int) (result *big.Int) { | |
defer timeTrack(time.Now(), "factorial") | |
// ... do some things, maybe even return under some condition | |
return n | |
} | |
// ref: https://coderwall.com/p/cp5fya/measuring-execution-time-in-go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment