Skip to content

Instantly share code, notes, and snippets.

@serverhorror
Created October 15, 2012 09:19
Show Gist options
  • Select an option

  • Save serverhorror/3891617 to your computer and use it in GitHub Desktop.

Select an option

Save serverhorror/3891617 to your computer and use it in GitHub Desktop.
func RecordTime(start time.Time) {
pc, _, _,ok := runtime.Caller(0)
caller := runtime.FuncForPC(pc)
elapsed := time.Since(start)
if ok {
log.Printf("Function `%s` took `%s`",
caller.Name(), elapsed)
} else {
log.Printf("UNKNOWN Function took `%s`", elapsed)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment