1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/cmd/cli/app/timer.go

28 lines
356 B
Go
Raw Normal View History

2018-09-18 22:42:38 +02:00
package app
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())
}