Skip to content

Commit 9742898

Browse files
committed
bench/tpcc: clean up benchmark names
Release note: None
1 parent 2541bc7 commit 9742898

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

pkg/bench/tpcc/bench_test.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,28 @@ func BenchmarkTPCC(b *testing.B) {
4343
}
4444
})
4545

46-
for _, impl := range []string{"literal", "optimized"} {
47-
b.Run(impl, func(b *testing.B) {
48-
var baseFlag string
49-
if impl == "literal" {
50-
baseFlag = workloadFlag("literal-implementation", "true")
51-
}
52-
for _, mixFlag := range []string{
53-
workloadFlag("mix", "newOrder=1"),
54-
workloadFlag("mix", "payment=1"),
55-
workloadFlag("mix", "orderStatus=1"),
56-
workloadFlag("mix", "delivery=1"),
57-
workloadFlag("mix", "stockLevel=1"),
58-
workloadFlag("mix", "newOrder=10,payment=10,orderStatus=1,delivery=1,stockLevel=1"),
46+
for _, impl := range []struct{ name, flag string }{
47+
{"literal", "--literal-implementation=true"},
48+
{"optimized", "--literal-implementation=false"},
49+
} {
50+
b.Run(impl.name, func(b *testing.B) {
51+
for _, mix := range []struct{ name, flag string }{
52+
{"new_order", "--mix=newOrder=1"},
53+
{"payment", "--mix=payment=1"},
54+
{"order_status", "--mix=orderStatus=1"},
55+
{"delivery", "--mix=delivery=1"},
56+
{"stock_level", "--mix=stockLevel=1"},
57+
{"default", "--mix=newOrder=10,payment=10,orderStatus=1,delivery=1,stockLevel=1"},
5958
} {
60-
b.Run(mixFlag, func(b *testing.B) {
61-
run(b, storeDir, []string{baseFlag, mixFlag})
59+
b.Run(mix.name, func(b *testing.B) {
60+
run(b, storeDir, []string{impl.flag, mix.flag})
6261
})
6362
}
6463
})
6564

6665
}
6766
}
6867

69-
func workloadFlag(name, value string) string {
70-
return name + "=" + value
71-
}
72-
7368
func run(b *testing.B, storeDir string, workloadFlags []string) {
7469
pgURL, closeServer := startCockroach(b, storeDir)
7570
defer closeServer()

pkg/bench/tpcc/utils_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ func (c cmd) withEnv(k string, v any) cmd {
3636
return c
3737
}
3838

39+
// exec executes the command in a subprocess. The args should be in the form
40+
// "--arg=value". It returns the command, which has not yet been executed, and a
41+
// buffer where the STDOUT and STDERR of the subprocess will be written.
3942
func (c cmd) exec(args ...string) (ec *exec.Cmd, output *synchronizedBuffer) {
4043
ec = exec.Command(os.Args[0], "--test.run=^"+c.name+"$", "--test.v")
4144
if len(args) > 0 {
45+
ec.Args = append(ec.Args, "--")
4246
}
43-
for i, arg := range args {
44-
if i == 0 {
45-
ec.Args = append(ec.Args, "--")
46-
}
47-
ec.Args = append(ec.Args, "--"+arg)
48-
}
49-
ec.Env = os.Environ()
50-
ec.Env = append(ec.Env, c.envVars...)
47+
ec.Args = append(ec.Args, args...)
48+
ec.Env = append(os.Environ(), c.envVars...)
5149
output = new(synchronizedBuffer)
5250
ec.Stdout, ec.Stderr = output, output
5351
return ec, output

0 commit comments

Comments
 (0)