diff options
Diffstat (limited to 'cmd/bolt')
-rw-r--r-- | cmd/bolt/bench.go | 9 | ||||
-rw-r--r-- | cmd/bolt/main.go | 8 |
2 files changed, 10 insertions, 7 deletions
diff --git a/cmd/bolt/bench.go b/cmd/bolt/bench.go index e1858df..10a5599 100644 --- a/cmd/bolt/bench.go +++ b/cmd/bolt/bench.go @@ -23,6 +23,13 @@ var benchBucketName = []byte("bench") func Bench(options *BenchOptions) { var results BenchResults + // Validate options. + if options.BatchSize == 0 { + options.BatchSize = options.Iterations + } else if options.Iterations%options.BatchSize != 0 { + fatal("number of iterations must be divisible by the batch size") + } + // Find temporary location. path := tempfile() defer os.Remove(path) @@ -232,9 +239,9 @@ type BenchOptions struct { WriteMode string ReadMode string Iterations int + BatchSize int KeySize int ValueSize int - BatchSize int CPUProfile string MemProfile string BlockProfile string diff --git a/cmd/bolt/main.go b/cmd/bolt/main.go index 041f4bb..cb2d47a 100644 --- a/cmd/bolt/main.go +++ b/cmd/bolt/main.go @@ -98,26 +98,22 @@ func NewApp() *cli.App { &cli.StringFlag{Name: "write-mode", Value: "seq", Usage: "Write mode"}, &cli.StringFlag{Name: "read-mode", Value: "seq", Usage: "Read mode"}, &cli.IntFlag{Name: "count", Value: 1000, Usage: "Item count"}, + &cli.IntFlag{Name: "batch-size", Usage: "Write batch size"}, &cli.IntFlag{Name: "key-size", Value: 8, Usage: "Key size"}, &cli.IntFlag{Name: "value-size", Value: 32, Usage: "Value size"}, - &cli.IntFlag{Name: "batch-size", Value: 0, Usage: "Write batch size"}, &cli.StringFlag{Name: "cpuprofile", Usage: "CPU profile output path"}, &cli.StringFlag{Name: "memprofile", Usage: "Memory profile output path"}, &cli.StringFlag{Name: "blockprofile", Usage: "Block profile output path"}, }, Action: func(c *cli.Context) { - bs := c.Int("batch-size") - if bs == 0 { - bs = c.Int("count") - } Bench(&BenchOptions{ ProfileMode: c.String("profile-mode"), WriteMode: c.String("write-mode"), ReadMode: c.String("read-mode"), Iterations: c.Int("count"), + BatchSize: c.Int("batch-size"), KeySize: c.Int("key-size"), ValueSize: c.Int("value-size"), - BatchSize: bs, CPUProfile: c.String("cpuprofile"), MemProfile: c.String("memprofile"), BlockProfile: c.String("blockprofile"), |