Added a logging system to show home much time it
took to do a certain part of the program
This commit is contained in:
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user