mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-19 04:10:30 +08:00
优化代码
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func StartMemoryStats(t *testing.T) {
|
||||
func StartMemoryStatsGC(t *testing.T) {
|
||||
var ticker = time.NewTicker(1 * time.Second)
|
||||
go func() {
|
||||
var stat = &runtime.MemStats{}
|
||||
@@ -31,3 +31,21 @@ func StartMemoryStats(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func StartMemoryStats(t *testing.T) {
|
||||
var ticker = time.NewTicker(1 * time.Second)
|
||||
go func() {
|
||||
var stat = &runtime.MemStats{}
|
||||
var lastHeapInUse uint64
|
||||
|
||||
for range ticker.C {
|
||||
runtime.ReadMemStats(stat)
|
||||
if stat.HeapInuse == lastHeapInUse {
|
||||
return
|
||||
}
|
||||
lastHeapInUse = stat.HeapInuse
|
||||
|
||||
t.Log(timeutil.Format("H:i:s"), "HeapInuse:", fmt.Sprintf("%.2fM", float64(stat.HeapInuse)/1024/1024), "NumGC:", stat.NumGC)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user