Files

28 lines
495 B
Go
Raw Permalink Normal View History

2021-12-01 14:32:33 -05:00
package timer
import (
2021-12-15 16:52:42 -05:00
"AoC2021/utils/color"
"AoC2021/utils/log"
2021-12-01 14:32:33 -05:00
"fmt"
"time"
)
var lastTime time.Time
func Start() {
lastTime = time.Now()
}
func Tick() {
now := time.Now()
2021-12-15 16:52:42 -05:00
fmt.Printf(color.Yellow+"[Time taken: %s]\n"+color.Reset, now.Sub(lastTime).String())
2021-12-01 14:32:33 -05:00
lastTime = now
}
2021-12-15 16:52:42 -05:00
func TickAtLevel(logLevel int) {
if log.LOG_LEVEL >= logLevel {
now := time.Now()
log.Printf(logLevel, color.Yellow+"[Time taken: %s]\n"+color.Reset, now.Sub(lastTime).String())
lastTime = now
}
}