Add a MemUsage() helper
This commit is contained in:
parent
5c86191e43
commit
10986aba62
|
@ -3,7 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
@ -153,3 +155,12 @@ func ExtractHostAndPort(str string, defaultPort int) (host string, port int) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MemUsage() {
|
||||||
|
var m runtime.MemStats
|
||||||
|
runtime.ReadMemStats(&m)
|
||||||
|
fmt.Printf("Alloc = %v MiB", m.Alloc/1024/1024)
|
||||||
|
fmt.Printf("\tTotalAlloc = %v MiB", m.TotalAlloc/1024/1024)
|
||||||
|
fmt.Printf("\tSys = %v MiB", m.Sys/1024/1024)
|
||||||
|
fmt.Printf("\tNumGC = %v\n", m.NumGC)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue