From 4fd836c0b656b847b8cf4a1cb08748a71a9e3d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Majdand=C5=BEi=C4=87?= Date: Fri, 28 Jun 2024 17:23:13 +0200 Subject: [PATCH] Update instrumentation --- .gitignore | 1 + downloader/main.go | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index faf7207..0c31076 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ main.exe logs.log ws-server/deploy.tar +downloader/main.log diff --git a/downloader/main.go b/downloader/main.go index 3e86bd0..a971674 100644 --- a/downloader/main.go +++ b/downloader/main.go @@ -18,12 +18,23 @@ func init() { // var m runtime.MemStats // runtime.ReadMemStats(&m) +// // log.Printf("%+v", m) -// malloc := float64(m.Alloc) -// ramUsedMB := malloc / 1024 / 1024 -// kbPerGoroutine := malloc / 1024 / float64(numGoroutines) +// sys := float64(m.Sys) +// ramUsedMB := sys / 1024 / 1024 +// kbPerGoroutine := sys / 1024 / float64(numGoroutines) -// log.Printf("Number of active goroutines: %d; RAM used: %.2f MB; KB per goroutine: %.2f", numGoroutines, ramUsedMB, kbPerGoroutine) +// var numGoroutinesPretty string +// switch { +// case numGoroutines >= 1_000_000: +// numGoroutinesPretty = fmt.Sprintf("%.2fM", float64(numGoroutines)/1_000_000) +// case numGoroutines >= 1_000: +// numGoroutinesPretty = fmt.Sprintf("%.2fk", float64(numGoroutines)/1_000) +// default: +// numGoroutinesPretty = fmt.Sprintf("%d", numGoroutines) +// } + +// log.Printf("Number of active goroutines: %d (%s); RAM used: %.2f MB; KB per goroutine: %.2f", numGoroutines, numGoroutinesPretty, ramUsedMB, kbPerGoroutine) // } func main() { @@ -67,7 +78,7 @@ func main() { go func() { for { ws = WSConnection{ - url: WEBSOCKET_SERVER, + url: WEBSOCKET_SERVER_ALT, } ws.Open() for {