]> Cypherpunks repositories - gostls13.git/commitdiff
test/bench/garbage: fix parser benchmark
authorDmitriy Vyukov <dvyukov@google.com>
Thu, 5 Apr 2012 16:35:54 +0000 (20:35 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Thu, 5 Apr 2012 16:35:54 +0000 (20:35 +0400)
+add standard bench output to tree2
+print GOMAXPROCS as go test does

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5992044

test/bench/garbage/parser.go
test/bench/garbage/stats.go
test/bench/garbage/tree2.go

index d66281b6bf49d6fbda1f391709b956260123792c..b91e0248f534058b77912be87ed857e263917824 100644 (file)
@@ -195,7 +195,6 @@ var packages = []string{
        "mime",
        "net",
        "os",
-       "exp/signal",
        "path",
        "math/rand",
        "reflect",
@@ -215,7 +214,6 @@ var packages = []string{
        "testing",
        "testing/iotest",
        "testing/quick",
-       "testing/script",
        "time",
        "unicode",
        "unicode/utf8",
index cdcb32f9b65826845cad2d13355ea57e8fd8e7c2..6dc0aeb2331140d96701cdcefeba6886c89f7a84 100644 (file)
@@ -14,16 +14,21 @@ import (
 func gcstats(name string, n int, t time.Duration) {
        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))])
-       fmt.Printf("garbage.%sPause %d %d ns/op\n", name, st.NumGC, int64(st.PauseTotalNs)/int64(st.NumGC))
+       nprocs := runtime.GOMAXPROCS(-1)
+       cpus := ""
+       if nprocs != 1 {
+               cpus = fmt.Sprintf("-%d", nprocs)
+       }
+       fmt.Printf("garbage.%sMem%s Alloc=%d/%d Heap=%d NextGC=%d Mallocs=%d\n", name, cpus, st.Alloc, st.TotalAlloc, st.Sys, st.NextGC, st.Mallocs)
+       fmt.Printf("garbage.%s%s %d %d ns/op\n", name, cpus, n, t.Nanoseconds()/int64(n))
+       fmt.Printf("garbage.%sLastPause%s 1 %d ns/op\n", name, cpus, st.PauseNs[(st.NumGC-1)%uint32(len(st.PauseNs))])
+       fmt.Printf("garbage.%sPause%s %d %d ns/op\n", name, cpus, st.NumGC, int64(st.PauseTotalNs)/int64(st.NumGC))
        nn := int(st.NumGC)
        if nn >= len(st.PauseNs) {
                nn = len(st.PauseNs)
        }
        t1, t2, t3, t4, t5 := tukey5(st.PauseNs[0:nn])
-       fmt.Printf("garbage.%sPause5: %d %d %d %d %d\n", name, t1, t2, t3, t4, t5)
+       fmt.Printf("garbage.%sPause5%s: %d %d %d %d %d\n", name, cpus, t1, t2, t3, t4, t5)
 
        //      fmt.Printf("garbage.%sScan: %v\n", name, st.ScanDist)
 }
index 3db0a0ba3c3a1939888b90b5366922f18007d25b..a171c696bbc5d7484a449416d29acfeba028a884 100644 (file)
@@ -11,6 +11,7 @@ import (
        "os"
        "runtime"
        "runtime/pprof"
+       "time"
        "unsafe"
 )
 
@@ -83,7 +84,12 @@ func main() {
                pprof.StartCPUProfile(f)
                defer pprof.StopCPUProfile()
        }
-       for i := 0; i < 10; i++ {
+       const N = 10
+       var t0 time.Time
+       for i := 0; i < N; i++ {
+               t0 = time.Now()
                gc()
        }
+       // Standard gotest benchmark output, collected by build dashboard.
+       gcstats("BenchmarkTree2", N, time.Now().Sub(t0))
 }