Added a logging system to show home much time it

took to do a certain part of the program
This commit is contained in:
Karma Riuk
2023-08-10 19:38:43 +02:00
parent 42cc4f8717
commit 144d3c2aed
6 changed files with 22 additions and 0 deletions

View File

@ -1,8 +1,10 @@
package utils
import (
"fmt"
"log"
"testing"
"time"
"golang.org/x/exp/constraints"
)
@ -27,3 +29,14 @@ func AssertEqual[T comparable](t *testing.T, got T, want T, msg string, args ...
t.Fatalf(msg+"\nGot: %v, Want: %v", args...)
}
}
var VERBOSE_LEVEL int
func Timer(msg string, level int) func() {
start := time.Now()
return func() {
if level <= VERBOSE_LEVEL {
fmt.Printf("%-19s %12v\n", msg, time.Since(start))
}
}
}