mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
28 lines
356 B
Go
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())
|
|
}
|