mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 08:35:55 +00:00
simplify and rename SetBits Benchmark
This commit is contained in:
parent
6c42e8b7e7
commit
e6b31db90d
2 changed files with 18 additions and 33 deletions
|
|
@ -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"},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
`)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue