Memory usage optimization
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package rrc
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func searchVL(V []float64, Sik float64) int {
|
||||
left, right := 0, len(V)-2
|
||||
|
||||
@@ -24,3 +31,16 @@ func searchVL(V []float64, Sik float64) int {
|
||||
// Return -1 if no such position is found
|
||||
return -1
|
||||
}
|
||||
|
||||
var lastTotalFreed uint64
|
||||
|
||||
func printMemStats() {
|
||||
var m runtime.MemStats
|
||||
runtime.ReadMemStats(&m)
|
||||
log.Printf("[Memory] Alloc = %v TotalAlloc=%v Just Freed = %v Sys = %v NumGc=%v",
|
||||
humanize.Bytes(m.Alloc),
|
||||
humanize.Bytes(m.TotalAlloc),
|
||||
humanize.Bytes(((m.TotalAlloc - m.Alloc) - lastTotalFreed)),
|
||||
humanize.Bytes(m.Sys), m.NumGC)
|
||||
lastTotalFreed = m.TotalAlloc - m.Alloc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user