Adjust how performance logging is managed

This commit is contained in:
Fred Boniface 2024-04-13 21:45:05 +01:00
parent dc958ac717
commit 16fa1c5354

View File

@ -1,7 +1,7 @@
package background
import (
"fmt"
"math"
"runtime"
"time"
@ -9,6 +9,7 @@ import (
"git.fjla.uk/owlboard/timetable-mgr/corpus"
"git.fjla.uk/owlboard/timetable-mgr/helpers"
"git.fjla.uk/owlboard/timetable-mgr/log"
"go.uber.org/zap"
)
const frequency = 2 * time.Hour // Figure out a sensible frequency!
@ -60,7 +61,8 @@ func debugLog() {
runtime.ReadMemStats(&memStats)
goroutines := runtime.NumGoroutine()
heapMem := float64(memStats.HeapAlloc) / (1024 * 1024)
heapMemRound := math.Round(heapMem*100) / 100
fmt.Printf("\nNumber of goroutines: %d\n", goroutines)
fmt.Printf("Heap Allocated memory: %2f MB\n\n", float64(memStats.HeapAlloc)/(1024*1024))
log.Msg.Debug("Performance", zap.Int("goroutine-count", goroutines), zap.Float64("heap-mem (MB)", heapMemRound))
}