Skip to content

Commit 1b4246d

Browse files
committed
fixed mode
1 parent 846e10d commit 1b4246d

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

benchmark/benchmark.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ type (
2323
TableSize int `long:"table_size" description:"number of rows per table" default:"10000"`
2424
DBDriver string `long:"db-driver" choice:"mysql" choice:"pgsql" choice:"spanner" description:"specifies database driver to use" default:"mysql"` //nolint:staticcheck
2525
DBPreparedStmt string `long:"db-ps-mode" choice:"auto" choice:"disable" description:"prepared statements usage mode" default:"auto"` //nolint:staticcheck
26-
ReadWrite bool
2726
}
2827
BenchmarkOpts struct {
2928
CommonOpts
@@ -34,8 +33,10 @@ type (
3433
)
3534

3635
func BenchmarkFactory(testname string, opt *BenchmarkOpts) (Benchmark, error) {
37-
if testname == "oltp_read_only" || testname == "oltp_read_write" {
38-
return newOLTPBench(opt), nil
36+
if testname == "oltp_read_only" {
37+
return newOLTPBench(opt, rwModeReadOnly), nil
38+
} else if testname == "oltp_read_write" {
39+
return newOLTPBench(opt, rwModeReadWrite), nil
3940
}
4041
return nil, fmt.Errorf("Unknown benchmark: %s", testname)
4142

benchmark/oltpbench.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ const (
5454
OptMySQLIgnoreErrsAll = "all"
5555
OptDBPreparedStmtAuto = "auto"
5656
OptDBPreparedStmtDisable = "disable"
57+
58+
rwModeReadOnly = "ro"
59+
rwModeReadWrite = "rw"
5760
)
5861

5962
var stmtsMySQL map[string]string = map[string]string{
@@ -109,13 +112,14 @@ type (
109112
OLTPBench struct {
110113
opts *BenchmarkOpts
111114

115+
rwMode string
112116
mysqlIgnoreErrsSlice []uint16
113117
db *sql.DB
114118
}
115119
)
116120

117-
func newOLTPBench(option *BenchmarkOpts) *OLTPBench {
118-
return &OLTPBench{opts: option}
121+
func newOLTPBench(option *BenchmarkOpts, mode string) *OLTPBench {
122+
return &OLTPBench{opts: option, rwMode: mode}
119123
}
120124

121125
func (o *OLTPBench) Init(ctx context.Context) error {
@@ -257,7 +261,7 @@ func (o *OLTPBench) Event(ctx context.Context) (reads uint64, writes uint64, oth
257261
numReads += 1
258262
}
259263

260-
if o.opts.ReadWrite {
264+
if o.rwMode == rwModeReadWrite {
261265
for i := 0; i < numIndexUpdates; i++ {
262266
_, err := tx.ExecContext(ctx, fmt.Sprintf(stmts["stmtIndexUpdates"], tableNum), sbRand(0, o.opts.TableSize))
263267
if err != nil {

cmd/go-sysbench/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package main
1717
// 61. ignore-error 数のレポート
1818
// 62. --mysql-ignore-errors の場合 others にカウントする
1919

20-
2120
import (
2221
"log"
2322
"os"

0 commit comments

Comments
 (0)