From a42d74da7e6b3162701ae17d59647a6880ccb6bf Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Fri, 18 Apr 2014 21:37:45 -0500 Subject: Add 'bolt bench'. This commit adds a flexible benchmarking tool to the 'bolt' CLI. It allows the user to separately specify the write mode and read mode (e.g. sequential random, etc). It also allows the user to isolate profiling to either the read or the writes. Currently the bench tool only supports "seq" read and write modes. It also does not support streaming of Bolt counters yet. Fixes #95. /cc @snormore --- cmd/bolt/main.go | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'cmd/bolt/main.go') diff --git a/cmd/bolt/main.go b/cmd/bolt/main.go index ac71631..719bf00 100644 --- a/cmd/bolt/main.go +++ b/cmd/bolt/main.go @@ -6,7 +6,6 @@ import ( "fmt" "log" "os" - "strconv" "github.com/codegangsta/cli" ) @@ -91,31 +90,34 @@ func NewApp() *cli.App { Check(path) }, }, - { - Name: "generate", - Usage: "Generate data for benchmarks", - Action: func(c *cli.Context) { - destPath := c.Args().Get(0) - numBuckets, err := strconv.Atoi(c.Args().Get(1)) - if err != nil { - fatal(err) - } - numItems, err := strconv.Atoi(c.Args().Get(2)) - if err != nil { - fatal(err) - } - Generate(destPath, numBuckets, numItems) - }, - }, { Name: "bench", - Usage: "Run benchmarks on a given dataset", + Usage: "Performs a synthetic benchmark", + Flags: []cli.Flag{ + &cli.StringFlag{Name: "profile-mode", Value: "rw", Usage: "Profile mode"}, + &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: "key-size", Value: 8, Usage: "Key size"}, + &cli.IntFlag{Name: "value-size", Value: 32, Usage: "Value 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) { - srcPath := c.Args().Get(0) - Bench(srcPath, "read", "sequential", 1) + Bench(&BenchOptions{ + ProfileMode: c.String("profile-mode"), + WriteMode: c.String("write-mode"), + ReadMode: c.String("read-mode"), + Iterations: c.Int("count"), + KeySize: c.Int("key-size"), + ValueSize: c.Int("value-size"), + CPUProfile: c.String("cpuprofile"), + MemProfile: c.String("memprofile"), + BlockProfile: c.String("blockprofile"), + }) }, - }, - } + }} return app } -- cgit v1.2.3