1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/cli/timer.go
2018-10-04 22:13:52 -04:00

28 lines
356 B
Go

package cli
import (
"fmt"
"time"
)
type Timer struct {
start time.Time
duration time.Duration
}
func NewTimer() *Timer {
return &Timer{}
}
func (t *Timer) Start() {
t.start = time.Now()
}
func (t *Timer) Stop() {
t.duration = time.Since(t.start)
}
func (t *Timer) Print() string {
return fmt.Sprintf("%f seconds", t.duration.Seconds())
}