From e6b31db90d8d97710aeeb8a022d385fa94b1daf2 Mon Sep 17 00:00:00 2001 From: jaffee Date: Thu, 10 Nov 2016 17:02:30 -0600 Subject: [PATCH] simplify and rename SetBits Benchmark --- bench/bench.go | 45 +++++++++++++++---------------------------- cmd/pilosactl/main.go | 6 +++--- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/bench/bench.go b/bench/bench.go index d7fe91fae..f8be2acf3 100644 --- a/bench/bench.go +++ b/bench/bench.go @@ -36,9 +36,8 @@ type Command interface { Usage() string } -// SetBits sets a bunch of bits in pilosa, and can be configured in a -// number of ways. -type SetBits struct { +// DiagonalSetBits sets bits with increasing profile id and bitmap id. +type DiagonalSetBits struct { cli *pilosa.Client // bits being set will all be greater than BaseBitmapID. BaseBitmapID int @@ -46,23 +45,20 @@ type SetBits struct { BaseProfileID int // Iterations is the number of bits that will be set by this Benchmark. Iterations int - // Number of profiles to iterate through - in this way multiple bits may be - // set on the same profile. - NumProfiles int // DB to use in pilosa. DB string } -func (b *SetBits) Usage() string { +func (b *DiagonalSetBits) Usage() string { return ` -SetBits sets a bunch of bits. +DiagonalSetBits sets bits with increasing profile id and bitmap id. -Usage: SetBits [arguments] +Usage: DiagonalSetBits [arguments] The following arguments are available: -BaseBitmapID int - bit num to start from + bitmap id to start from -BaseProfileID int profile id num to start from @@ -70,21 +66,17 @@ The following arguments are available: -Iterations int number of bits to set - -NumProfiles int - number of profiles to loop through - -DB string pilosa db to use `[1:] } -func (b *SetBits) ConsumeFlags(args []string) ([]string, error) { - fs := flag.NewFlagSet("SetBits", flag.ContinueOnError) +func (b *DiagonalSetBits) ConsumeFlags(args []string) ([]string, error) { + fs := flag.NewFlagSet("DiagonalSetBits", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.IntVar(&b.BaseBitmapID, "BaseBitmapID", 0, "bits being set will all be greater than BaseBitmapID") fs.IntVar(&b.BaseProfileID, "BaseProfileID", 0, "profile ids used will all be greater than BaseProfileID") fs.IntVar(&b.Iterations, "Iterations", 100, "Iterations is the number of bits that will be set by this Benchmark") - fs.IntVar(&b.NumProfiles, "NumProfiles", 100, "number of profiles to iterate through") fs.StringVar(&b.DB, "DB", "benchdb", "pilosa DB to use") if err := fs.Parse(args); err != nil { @@ -94,31 +86,28 @@ func (b *SetBits) ConsumeFlags(args []string) ([]string, error) { } // Init connects to pilosa and sets the client on b. -func (b *SetBits) Init(hosts []string) (err error) { +func (b *DiagonalSetBits) Init(hosts []string) (err error) { b.cli, err = pilosa.NewClient(hosts[0]) if err != nil { return err } - if b.Iterations == 0 { - b.Iterations = 100 - } if b.DB == "" { - b.DB = "SetBits" + b.DB = "DiagonalSetBits" } return nil } -// Run runs the SetBits benchmark -func (b *SetBits) Run(agentNum int) map[string]interface{} { +// Run runs the DiagonalSetBits benchmark +func (b *DiagonalSetBits) Run(agentNum int) map[string]interface{} { results := make(map[string]interface{}) if b.cli == nil { - results["error"] = fmt.Errorf("No client set for SetBits agent: %v", agentNum) + results["error"] = fmt.Errorf("No client set for DiagonalSetBits agent: %v", agentNum) return results } for n := 0; n < b.Iterations; n++ { iterID := agentizeNum(n, b.Iterations, agentNum) - query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+iterID, b.BaseProfileID+iterID%b.NumProfiles) - b.cli.ExecuteQuery("2", query, true) + query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+iterID, b.BaseProfileID+iterID) + b.cli.ExecuteQuery(b.DB, query, true) } return results } @@ -226,7 +215,3 @@ func Serial(bs ...Benchmark) Benchmark { benchmarkers: bs, } } - -var Benchmarks = map[string]Benchmark{ - "SetContiguousBits": &SetBits{Iterations: 100000, NumProfiles: 1000, DB: "setcontiguousbench"}, -} diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index 57fed6a8e..4f661d7b0 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -1304,8 +1304,8 @@ func (cmd *BagentCommand) ParseFlags(args []string) error { switch remArgs[0] { case "-help", "-h": return flag.ErrHelp - case "SetBits": - bm = &bench.SetBits{} + case "DiagonalSetBits": + bm = &bench.DiagonalSetBits{} default: return fmt.Errorf("Unknown benchmark cmd: %v", remArgs[0]) } @@ -1342,7 +1342,7 @@ The following arguments are available: An integer differentiating this agent from others in the fleet. subcommands: - SetBits + DiagonalSetBits `) }