sweet: add GOMAXPROCS suffix to benchmark names
This change adds the GOMAXPROCS suffix to benchmark names the same way that `go test` does. Change-Id: I3ae168620de716c0aa8b642d099ba5308c54f48b Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/580837 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>pull/11/head
parent
d10bd6dc28
commit
d78363a64b
|
@ -45,6 +45,7 @@ type config struct {
|
|||
isProfiling bool
|
||||
short bool
|
||||
procsPerInst int
|
||||
gomaxprocs int
|
||||
bench *benchmark
|
||||
}
|
||||
|
||||
|
@ -68,6 +69,7 @@ func init() {
|
|||
}
|
||||
runtime.GOMAXPROCS(procsPerInst)
|
||||
cliCfg.procsPerInst = procsPerInst
|
||||
cliCfg.gomaxprocs = procs
|
||||
}
|
||||
|
||||
type etcdInstance struct {
|
||||
|
@ -357,6 +359,7 @@ func run(cfg *config) (err error) {
|
|||
driver.DoCoreDump(true),
|
||||
driver.BenchmarkPID(instances[0].cmd.Process.Pid),
|
||||
driver.DoPerf(true),
|
||||
driver.WithGOMAXPROCS(cfg.gomaxprocs),
|
||||
}
|
||||
return driver.RunBenchmark(cfg.bench.reportName, func(d *driver.B) error {
|
||||
// Set up diagnostics.
|
||||
|
|
|
@ -159,7 +159,7 @@ func (b httpServer) run(cfg *config, out io.Writer) (err error) {
|
|||
return fmt.Errorf("server startup timed out")
|
||||
}
|
||||
return nil
|
||||
}, driver.DoTime(true))
|
||||
}, driver.DoTime(true), driver.WithGOMAXPROCS(procs))
|
||||
|
||||
workers := make([]pool.Worker, 0, clients)
|
||||
for i := 0; i < clients; i++ {
|
||||
|
@ -202,5 +202,5 @@ func (b httpServer) run(cfg *config, out io.Writer) (err error) {
|
|||
d.Ops(len(latencies))
|
||||
d.Report(driver.StatTime, uint64((int(b.duration)*clients)/len(latencies)))
|
||||
return nil
|
||||
}, driver.DoTime(true), driver.DoAvgRSS(srvCmd.RSSFunc()))
|
||||
}, driver.DoTime(true), driver.DoAvgRSS(srvCmd.RSSFunc()), driver.WithGOMAXPROCS(procs))
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"runtime/trace"
|
||||
"sort"
|
||||
|
@ -129,6 +130,12 @@ func WriteResultsTo(wr io.Writer) RunOption {
|
|||
}
|
||||
}
|
||||
|
||||
func WithGOMAXPROCS(procs int) RunOption {
|
||||
return func(b *B) {
|
||||
b.gomaxprocs = procs
|
||||
}
|
||||
}
|
||||
|
||||
var InProcessMeasurementOptions = []RunOption{
|
||||
DoTime(true),
|
||||
DoPeakRSS(true),
|
||||
|
@ -151,6 +158,7 @@ type B struct {
|
|||
doPeakRSS bool
|
||||
doPeakVM bool
|
||||
doCoreDump bool
|
||||
gomaxprocs int
|
||||
collectDiag map[diagnostics.Type]bool
|
||||
rssFunc func() (uint64, error)
|
||||
statsMu sync.Mutex
|
||||
|
@ -372,7 +380,11 @@ func (b *B) report() {
|
|||
if b.resultsWriter != nil {
|
||||
out = b.resultsWriter
|
||||
}
|
||||
fmt.Fprintf(out, "Benchmark%s %d", b.name, b.ops)
|
||||
suffix := ""
|
||||
if b.gomaxprocs > 1 {
|
||||
suffix = fmt.Sprintf("-%d", b.gomaxprocs)
|
||||
}
|
||||
fmt.Fprintf(out, "Benchmark%s%s %d", b.name, suffix, b.ops)
|
||||
for _, name := range names {
|
||||
value := b.stats[name]
|
||||
if value != 0 {
|
||||
|
@ -442,6 +454,11 @@ func RunBenchmark(name string, f func(*B) error, opts ...RunOption) error {
|
|||
opt(b)
|
||||
}
|
||||
|
||||
// Make sure gomaxprocs is set.
|
||||
if b.gomaxprocs == 0 {
|
||||
b.gomaxprocs = runtime.GOMAXPROCS(-1)
|
||||
}
|
||||
|
||||
// Start the RSS sampler and start the timer.
|
||||
stop := b.startRSSSampler()
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ type config struct {
|
|||
dataPath string
|
||||
tmpDir string
|
||||
serverProcs int
|
||||
gomaxprocs int
|
||||
isProfiling bool
|
||||
short bool
|
||||
}
|
||||
|
@ -82,6 +83,7 @@ func init() {
|
|||
}
|
||||
runtime.GOMAXPROCS(clientProcs)
|
||||
cliCfg.serverProcs = serverProcs
|
||||
cliCfg.gomaxprocs = procs
|
||||
}
|
||||
|
||||
func doWithinCircle(c redis.Conn, lat, lon float64) error {
|
||||
|
@ -328,6 +330,7 @@ func run(cfg *config) (err error) {
|
|||
driver.DoCoreDump(true),
|
||||
driver.BenchmarkPID(srvCmd.Process.Pid),
|
||||
driver.DoPerf(true),
|
||||
driver.WithGOMAXPROCS(cfg.gomaxprocs),
|
||||
}
|
||||
iters := 40 * 50000
|
||||
if cfg.short {
|
||||
|
|
Loading…
Reference in New Issue