mirror of
https://github.com/golang/go
synced 2024-11-22 05:24:39 -07:00
test/bench/garbage: fix parser benchmark
+add standard bench output to tree2 +print GOMAXPROCS as go test does R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5992044
This commit is contained in:
parent
fd04f05f2f
commit
77e1227a02
@ -195,7 +195,6 @@ var packages = []string{
|
|||||||
"mime",
|
"mime",
|
||||||
"net",
|
"net",
|
||||||
"os",
|
"os",
|
||||||
"exp/signal",
|
|
||||||
"path",
|
"path",
|
||||||
"math/rand",
|
"math/rand",
|
||||||
"reflect",
|
"reflect",
|
||||||
@ -215,7 +214,6 @@ var packages = []string{
|
|||||||
"testing",
|
"testing",
|
||||||
"testing/iotest",
|
"testing/iotest",
|
||||||
"testing/quick",
|
"testing/quick",
|
||||||
"testing/script",
|
|
||||||
"time",
|
"time",
|
||||||
"unicode",
|
"unicode",
|
||||||
"unicode/utf8",
|
"unicode/utf8",
|
||||||
|
@ -14,16 +14,21 @@ import (
|
|||||||
func gcstats(name string, n int, t time.Duration) {
|
func gcstats(name string, n int, t time.Duration) {
|
||||||
st := new(runtime.MemStats)
|
st := new(runtime.MemStats)
|
||||||
runtime.ReadMemStats(st)
|
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)
|
nprocs := runtime.GOMAXPROCS(-1)
|
||||||
fmt.Printf("garbage.%s %d %d ns/op\n", name, n, t.Nanoseconds()/int64(n))
|
cpus := ""
|
||||||
fmt.Printf("garbage.%sLastPause 1 %d ns/op\n", name, st.PauseNs[(st.NumGC-1)%uint32(len(st.PauseNs))])
|
if nprocs != 1 {
|
||||||
fmt.Printf("garbage.%sPause %d %d ns/op\n", name, st.NumGC, int64(st.PauseTotalNs)/int64(st.NumGC))
|
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)
|
nn := int(st.NumGC)
|
||||||
if nn >= len(st.PauseNs) {
|
if nn >= len(st.PauseNs) {
|
||||||
nn = len(st.PauseNs)
|
nn = len(st.PauseNs)
|
||||||
}
|
}
|
||||||
t1, t2, t3, t4, t5 := tukey5(st.PauseNs[0:nn])
|
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)
|
// fmt.Printf("garbage.%sScan: %v\n", name, st.ScanDist)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -83,7 +84,12 @@ func main() {
|
|||||||
pprof.StartCPUProfile(f)
|
pprof.StartCPUProfile(f)
|
||||||
defer pprof.StopCPUProfile()
|
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()
|
gc()
|
||||||
}
|
}
|
||||||
|
// Standard gotest benchmark output, collected by build dashboard.
|
||||||
|
gcstats("BenchmarkTree2", N, time.Now().Sub(t0))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user