Skip to content

kr/log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

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

No packages published

Languages