Skip to content

stopwatch is a small package to easily profile code in go.

License

Notifications You must be signed in to change notification settings

XotoX1337/stopwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference Go Report Card

stopwatch

stopwatch is a small package to easily profile code in go.

Download

go get github.com/XotoX1337/stopwatch

Examples

Single Section

import "github.com/XotoX1337/stopwatch"

watch := stopwatch.New()
section, err := watch.Start("foo")
if err != nil {
    fmt.Println(err)
}
//code to profile
section, err = section.Stop("foo")
if err != nil {
    fmt.Println(err)
}
fmt.Printf("execution took %s", section.Duration())

Time Laps within Sections

import "github.com/XotoX1337/stopwatch"

watch := stopwatch.New()
section, err := watch.Start("foo")
if err != nil {
    fmt.Println(err)
}
//code to profile
section.Lap()
//code to profile inside section "foo"
section.Lap()
//additional code to profile inside section "foo"

section, err = section.Stop("foo")
if err != nil {
    fmt.Println(err)
}
fmt.Printf("execution took %s", section.Duration())
for i, lap := range section.Laps() {
    fmt.Printf("%d. Lap took %s", i+1, lap.Duration())
}

About

stopwatch is a small package to easily profile code in go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published