From 0ac9ea7f571075414473ae32f3753dd30eb77a7e Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Tue, 22 Sep 2020 14:10:01 -0700 Subject: [PATCH] Add a test utility for timing the duration of things easily --- test/durationTimerTest.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/durationTimerTest.go diff --git a/test/durationTimerTest.go b/test/durationTimerTest.go new file mode 100644 index 000000000..43b5ce863 --- /dev/null +++ b/test/durationTimerTest.go @@ -0,0 +1,19 @@ +package test + +import ( + "time" + + log "github.com/sirupsen/logrus" +) + +var timestamp time.Time + +func Mark() { + now := time.Now() + if !timestamp.IsZero() { + delta := now.Sub(timestamp) + log.Println(delta.Milliseconds(), "ms") + } + + timestamp = now +}