diff options
author | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-02-06 19:16:26 +0100 |
---|---|---|
committer | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-02-06 19:16:26 +0100 |
commit | 842c906e2e9560187d4877d9f52e8f9ceb63d84c (patch) | |
tree | 218df3c83f3177d2f8ceccf20898d8e037c37042 /test/bench | |
parent | 9c060b8d60f14d930e5eadd7c9968ee2ba4f4131 (diff) | |
download | go-842c906e2e9560187d4877d9f52e8f9ceb63d84c.tar.gz go-842c906e2e9560187d4877d9f52e8f9ceb63d84c.zip |
runtime: delete UpdateMemStats, replace with ReadMemStats(&stats).
Unexports runtime.MemStats and rename MemStatsType to MemStats.
The new accessor requires passing a pointer to a user-allocated
MemStats structure.
Fixes #2572.
R=bradfitz, rsc, bradfitz, gustavo
CC=golang-dev, remy
https://golang.org/cl/5616072
Diffstat (limited to 'test/bench')
-rw-r--r-- | test/bench/garbage/parser.go | 20 | ||||
-rw-r--r-- | test/bench/garbage/stats.go | 3 | ||||
-rw-r--r-- | test/bench/garbage/tree2.go | 15 |
3 files changed, 20 insertions, 18 deletions
diff --git a/test/bench/garbage/parser.go b/test/bench/garbage/parser.go index 9e15f6c0f4..d66281b6bf 100644 --- a/test/bench/garbage/parser.go +++ b/test/bench/garbage/parser.go @@ -73,7 +73,7 @@ func parseDir(dirpath string) map[string]*ast.Package { } func main() { - st := &runtime.MemStats + st := new(runtime.MemStats) packages = append(packages, packages...) packages = append(packages, packages...) n := flag.Int("n", 4, "iterations") @@ -83,14 +83,17 @@ func main() { var lastParsed []map[string]*ast.Package var t0 time.Time + var numGC uint32 + var pauseTotalNs uint64 pkgroot := runtime.GOROOT() + "/src/pkg/" for pass := 0; pass < 2; pass++ { // Once the heap is grown to full size, reset counters. // This hides the start-up pauses, which are much smaller // than the normal pauses and would otherwise make // the average look much better than it actually is. - st.NumGC = 0 - st.PauseTotalNs = 0 + runtime.ReadMemStats(st) + numGC = st.NumGC + pauseTotalNs = st.PauseTotalNs t0 = time.Now() for i := 0; i < *n; i++ { @@ -107,6 +110,9 @@ func main() { } t1 := time.Now() + runtime.ReadMemStats(st) + st.NumGC -= numGC + st.PauseTotalNs -= pauseTotalNs fmt.Printf("Alloc=%d/%d Heap=%d Mallocs=%d PauseTime=%.3f/%d = %.3f\n", st.Alloc, st.TotalAlloc, st.Sys, @@ -142,9 +148,7 @@ var packages = []string{ "container/list", "container/ring", "crypto/aes", - "crypto/blowfish", "crypto/hmac", - "crypto/md4", "crypto/md5", "crypto/rand", "crypto/rc4", @@ -155,7 +159,6 @@ var packages = []string{ "crypto/subtle", "crypto/tls", "crypto/x509", - "crypto/xtea", "debug/dwarf", "debug/macho", "debug/elf", @@ -164,7 +167,6 @@ var packages = []string{ "encoding/ascii85", "encoding/base64", "encoding/binary", - "encoding/git85", "encoding/hex", "encoding/pem", "os/exec", @@ -193,8 +195,7 @@ var packages = []string{ "mime", "net", "os", - "os/signal", - "patch", + "exp/signal", "path", "math/rand", "reflect", @@ -219,6 +220,5 @@ var packages = []string{ "unicode", "unicode/utf8", "unicode/utf16", - "websocket", "encoding/xml", } diff --git a/test/bench/garbage/stats.go b/test/bench/garbage/stats.go index 985e7eaf5d..cdcb32f9b6 100644 --- a/test/bench/garbage/stats.go +++ b/test/bench/garbage/stats.go @@ -12,7 +12,8 @@ import ( ) func gcstats(name string, n int, t time.Duration) { - st := &runtime.MemStats + st := new(runtime.MemStats) + runtime.ReadMemStats(st) fmt.Printf("garbage.%sMem Alloc=%d/%d Heap=%d NextGC=%d Mallocs=%d\n", name, st.Alloc, st.TotalAlloc, st.Sys, st.NextGC, st.Mallocs) fmt.Printf("garbage.%s %d %d ns/op\n", name, n, t.Nanoseconds()/int64(n)) fmt.Printf("garbage.%sLastPause 1 %d ns/op\n", name, st.PauseNs[(st.NumGC-1)%uint32(len(st.PauseNs))]) diff --git a/test/bench/garbage/tree2.go b/test/bench/garbage/tree2.go index 6d78f72c5b..3db0a0ba3c 100644 --- a/test/bench/garbage/tree2.go +++ b/test/bench/garbage/tree2.go @@ -30,6 +30,7 @@ var ( heap *Object calls [20]int numobjects int64 + memstats runtime.MemStats ) func buildHeap() { @@ -55,10 +56,10 @@ func buildTree(objsize, size float64, depth int) (*Object, float64) { func gc() { runtime.GC() - runtime.UpdateMemStats() - pause := runtime.MemStats.PauseTotalNs - inuse := runtime.MemStats.Alloc - free := runtime.MemStats.TotalAlloc - inuse + runtime.ReadMemStats(&memstats) + pause := memstats.PauseTotalNs + inuse := memstats.Alloc + free := memstats.TotalAlloc - inuse fmt.Printf("gc pause: %8.3f ms; collect: %8.0f MB; heapsize: %8.0f MB\n", float64(pause-lastPauseNs)/1e6, float64(free-lastFree)/1048576, @@ -71,9 +72,9 @@ func main() { flag.Parse() buildHeap() runtime.GOMAXPROCS(*cpus) - runtime.UpdateMemStats() - lastPauseNs = runtime.MemStats.PauseTotalNs - lastFree = runtime.MemStats.TotalAlloc - runtime.MemStats.Alloc + runtime.ReadMemStats(&memstats) + lastPauseNs = memstats.PauseTotalNs + lastFree = memstats.TotalAlloc - memstats.Alloc if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { |