-
Notifications
You must be signed in to change notification settings - Fork 1
Conveniently log function duration
License
kr/log
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PACKAGE DOCUMENTATION package timer import "github.com/kr/log/timer" Package timer provides a wrapper for log.Print to measure the duration of a function's execution. It can be used conveniently in conjunction with "defer". The statement defer timer.Start().Print() prints the time elapsed between the call to Start (when the defer statement executes) and the call to Print (when the function returns). It can also be used, without defer, to log elapsed time to more than one point. The sequence t := timer.Start() // time-consuming code t.Print("first part") // more time-consuming code t.Print("total") prints the cumulative time from Start to each Print. Output is formatted with package text/template. All of the good ideas in this package came from @fabiokung, @bmizerany, and @davecheney.
About
Conveniently log function duration
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published