From da024fb0d8ddf7ecb95807ec41f6e9941060c5fa Mon Sep 17 00:00:00 2001 From: jaffee Date: Wed, 16 Nov 2016 08:44:22 -0600 Subject: [PATCH] add agentNum to benchmark Init as well as run --- bench/bench.go | 10 +++++----- bench/diagonal.go | 2 +- bench/multidb.go | 2 +- bench/random.go | 2 +- cmd/pilosactl/main.go | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bench/bench.go b/bench/bench.go index 872e2b31c..5c7808c7f 100644 --- a/bench/bench.go +++ b/bench/bench.go @@ -14,7 +14,7 @@ import ( type Benchmark interface { // Init takes a list of hosts and is generally expected to set up a // connection to pilosa using whatever client it chooses. - Init(hosts []string) error + Init(hosts []string, agentNum int) error // Run runs the benchmark. It takes an agentNum which should be used to // parameterize the benchmark if it is being run simultaneously on multiple @@ -49,7 +49,7 @@ type parallelBenchmark struct { // Init calls Init for each benchmark. If there are any errors, it will return a // non-nil error value. -func (pb *parallelBenchmark) Init(hosts []string) error { +func (pb *parallelBenchmark) Init(hosts []string, agentNum int) error { errors := make([]error, len(pb.benchmarkers)) hadErr := false wg := sync.WaitGroup{} @@ -57,7 +57,7 @@ func (pb *parallelBenchmark) Init(hosts []string) error { wg.Add(1) go func(i int, b Benchmark) { defer wg.Done() - errors[i] = b.Init(hosts) + errors[i] = b.Init(hosts, agentNum) if errors[i] != nil { hadErr = true } @@ -105,11 +105,11 @@ type serialBenchmark struct { // Init calls Init for each benchmark. If there are any errors, it will return a // non-nil error value. -func (sb *serialBenchmark) Init(hosts []string) error { +func (sb *serialBenchmark) Init(hosts []string, agentNum int) error { errors := make([]error, len(sb.benchmarkers)) hadErr := false for i, b := range sb.benchmarkers { - errors[i] = b.Init(hosts) + errors[i] = b.Init(hosts, agentNum) if errors[i] != nil { hadErr = true } diff --git a/bench/diagonal.go b/bench/diagonal.go index d16789eba..6caad1e49 100644 --- a/bench/diagonal.go +++ b/bench/diagonal.go @@ -56,7 +56,7 @@ func (b *DiagonalSetBits) ConsumeFlags(args []string) ([]string, error) { } // Init connects to pilosa and sets the client on b. -func (b *DiagonalSetBits) Init(hosts []string) (err error) { +func (b *DiagonalSetBits) Init(hosts []string, agentNum int) (err error) { b.cli, err = pilosa.NewClient(hosts[0]) if err != nil { return err diff --git a/bench/multidb.go b/bench/multidb.go index 620e1c12c..cd347f0e1 100644 --- a/bench/multidb.go +++ b/bench/multidb.go @@ -53,7 +53,7 @@ func (b *MultiDBSetBits) ConsumeFlags(args []string) ([]string, error) { } // Init connects to pilosa and sets the client on b. -func (b *MultiDBSetBits) Init(hosts []string) (err error) { +func (b *MultiDBSetBits) Init(hosts []string, agentNum int) (err error) { b.cli, err = pilosa.NewClient(hosts[0]) if err != nil { return err diff --git a/bench/random.go b/bench/random.go index 8e1eac121..8e92cdbea 100644 --- a/bench/random.go +++ b/bench/random.go @@ -73,7 +73,7 @@ func (b *RandomSetBits) ConsumeFlags(args []string) ([]string, error) { } // Init connects to pilosa and sets the client on b. -func (b *RandomSetBits) Init(hosts []string) (err error) { +func (b *RandomSetBits) Init(hosts []string, agentNum int) (err error) { b.cli, err = pilosa.NewClient(hosts[0]) if err != nil { return err diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index dbb06dbd6..903a32a7a 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -1369,7 +1369,7 @@ The following arguments are available: // Run executes the main program execution. func (cmd *BagentCommand) Run() error { sbm := bench.Serial(cmd.Benchmarks...) - err := sbm.Init(cmd.Hosts) + err := sbm.Init(cmd.Hosts, cmd.AgentNum) if err != nil { return fmt.Errorf("in cmd.Run initialization: %v", err) }