Skip to content

Instantly share code, notes, and snippets.

@kendellfab
Created November 20, 2013 23:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kendellfab/7572868 to your computer and use it in GitHub Desktop.
Save kendellfab/7572868 to your computer and use it in GitHub Desktop.
Golang time function.
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment