mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 00:25:55 +00:00
Merge pull request #217 from pilosa/benchmark-metadata
Benchmark metadata
This commit is contained in:
commit
35911e15d7
8 changed files with 58 additions and 30 deletions
|
|
@ -13,12 +13,18 @@ import (
|
|||
// DiagonalSetBits sets bits with increasing profile id and bitmap id.
|
||||
type DiagonalSetBits struct {
|
||||
HasClient
|
||||
Name string `json:"name"`
|
||||
BaseBitmapID int `json:"base-bitmap-id"`
|
||||
BaseProfileID int `json:"base-profile-id"`
|
||||
Iterations int `json:"iterations"`
|
||||
DB string `json:"db"`
|
||||
}
|
||||
|
||||
func (b *DiagonalSetBits) Init(hosts []string, agentNum int) error {
|
||||
b.Name = "diagonal-set-bits"
|
||||
return b.HasClient.Init(hosts, agentNum)
|
||||
}
|
||||
|
||||
func (b *DiagonalSetBits) Usage() string {
|
||||
return `
|
||||
diagonal-set-bits sets bits with increasing profile id and bitmap id.
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ func NewImport(stdin io.Reader, stdout, stderr io.Writer) *Import {
|
|||
|
||||
// Import sets bits with increasing profile id and bitmap id.
|
||||
type Import struct {
|
||||
Name string `json:"name"`
|
||||
BaseBitmapID int64 `json:"base-bitmap-id"`
|
||||
MaxBitmapID int64 `json:"max-bitmap-id"`
|
||||
BaseProfileID int64 `json:"base-profile-id"`
|
||||
|
|
@ -107,6 +108,7 @@ func (b *Import) Init(hosts []string, agentNum int) error {
|
|||
if len(hosts) == 0 {
|
||||
return fmt.Errorf("Need at least one host")
|
||||
}
|
||||
b.Name = "import"
|
||||
b.Host = hosts[0]
|
||||
// generate csv data
|
||||
baseBitmapID, maxBitmapID, baseProfileID, maxProfileID := b.BaseBitmapID, b.MaxBitmapID, b.BaseProfileID, b.MaxProfileID
|
||||
|
|
|
|||
|
|
@ -12,9 +12,15 @@ import (
|
|||
// MultiDBSetBits sets bits with increasing profile id and bitmap id.
|
||||
type MultiDBSetBits struct {
|
||||
HasClient
|
||||
BaseBitmapID int `json:"base-bitmap-id"`
|
||||
BaseProfileID int `json:"base-profile-id"`
|
||||
Iterations int `json:"iterations"`
|
||||
Name string `json:"name"`
|
||||
BaseBitmapID int `json:"base-bitmap-id"`
|
||||
BaseProfileID int `json:"base-profile-id"`
|
||||
Iterations int `json:"iterations"`
|
||||
}
|
||||
|
||||
func (b *MultiDBSetBits) Init(hosts []string, agentNum int) error {
|
||||
b.Name = "multi-db-set-bits"
|
||||
return b.HasClient.Init(hosts, agentNum)
|
||||
}
|
||||
|
||||
func (b *MultiDBSetBits) Usage() string {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import (
|
|||
// RandomSetBits sets bits randomly and deterministically based on a seed.
|
||||
type RandomSetBits struct {
|
||||
HasClient
|
||||
Name string `json:"name"`
|
||||
BaseBitmapID int64 `json:"base-bitmap-id"`
|
||||
BaseProfileID int64 `json:"base-profile-id"`
|
||||
BitmapIDRange int64 `json:"bitmap-id-range"`
|
||||
|
|
@ -23,6 +24,11 @@ type RandomSetBits struct {
|
|||
DB string `json:"db"`
|
||||
}
|
||||
|
||||
func (b *RandomSetBits) Init(hosts []string, agentNum int) error {
|
||||
b.Name = "random-set-bits"
|
||||
return b.HasClient.Init(hosts, agentNum)
|
||||
}
|
||||
|
||||
func (b *RandomSetBits) Usage() string {
|
||||
return `
|
||||
random-set-bits sets random bits
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
// RandomQuery queries randomly and deterministically based on a seed.
|
||||
type RandomQuery struct {
|
||||
HasClient
|
||||
Name string `json:"name"`
|
||||
MaxDepth int `json:"max-depth"`
|
||||
MaxArgs int `json:"max-args"`
|
||||
MaxN int `json:"max-n"`
|
||||
|
|
@ -22,6 +23,11 @@ type RandomQuery struct {
|
|||
DBs []string `json:"dbs"`
|
||||
}
|
||||
|
||||
func (b *RandomQuery) Init(hosts []string, agentNum int) error {
|
||||
b.Name = "random-query"
|
||||
return b.HasClient.Init(hosts, agentNum)
|
||||
}
|
||||
|
||||
func (b *RandomQuery) Usage() string {
|
||||
return `
|
||||
random-query constructs random queries
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ type SliceHeight struct {
|
|||
MaxTime time.Duration `json:"max-time"`
|
||||
hosts []string
|
||||
|
||||
Name string `json:"name"`
|
||||
MinBitsPerMap int64 `json:"min-bits-per-map"`
|
||||
MaxBitsPerMap int64 `json:"max-bits-per-map"`
|
||||
Seed int64 `json:"seed"`
|
||||
|
|
@ -84,6 +85,7 @@ func (b *SliceHeight) ConsumeFlags(args []string) ([]string, error) {
|
|||
}
|
||||
|
||||
func (b *SliceHeight) Init(hosts []string, agentNum int) error {
|
||||
b.Name = "slice-height"
|
||||
b.hosts = hosts
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,23 +17,22 @@ import (
|
|||
// It also uses PermutationGenerator to permute IDs randomly.
|
||||
type ZipfSetBits struct {
|
||||
HasClient
|
||||
BaseBitmapID int64
|
||||
BaseProfileID int64
|
||||
BitmapIDRange int64
|
||||
ProfileIDRange int64
|
||||
Iterations int // number of bits that will be set
|
||||
Seed int64
|
||||
BitmapRng *rand.Zipf
|
||||
ProfileRng *rand.Zipf
|
||||
BitmapPerm *PermutationGenerator
|
||||
ProfilePerm *PermutationGenerator
|
||||
DB string // DB to use in pilosa.
|
||||
|
||||
// TODO remove these - but theyre needed in ConsumeFlags
|
||||
BitmapExponent float64
|
||||
BitmapRatio float64
|
||||
ProfileExponent float64
|
||||
ProfileRatio float64
|
||||
Name string `json:"name"`
|
||||
BaseBitmapID int64 `json:"base-bitmap-id"`
|
||||
BaseProfileID int64 `json:"base-profile-id"`
|
||||
BitmapIDRange int64 `json:"bitmap-id-range"`
|
||||
ProfileIDRange int64 `json:"profile-id-range"`
|
||||
Iterations int `json:"iterations"`
|
||||
Seed int64 `json:"seed"`
|
||||
DB string `json:"db"`
|
||||
BitmapExponent float64 `json:"bitmap-exponent"`
|
||||
BitmapRatio float64 `json:"bitmap-ratio"`
|
||||
ProfileExponent float64 `json:"profile-exponent"`
|
||||
ProfileRatio float64 `json:"profile-ratio"`
|
||||
bitmapRng *rand.Zipf
|
||||
profileRng *rand.Zipf
|
||||
bitmapPerm *PermutationGenerator
|
||||
profilePerm *PermutationGenerator
|
||||
}
|
||||
|
||||
func (b *ZipfSetBits) Usage() string {
|
||||
|
|
@ -122,14 +121,15 @@ func getZipfOffset(N int64, exp, ratio float64) float64 {
|
|||
}
|
||||
|
||||
func (b *ZipfSetBits) Init(hosts []string, agentNum int) error {
|
||||
b.Name = "zipf-set-bits"
|
||||
rnd := rand.New(rand.NewSource(b.Seed + int64(agentNum)))
|
||||
bitmapOffset := getZipfOffset(b.BitmapIDRange, b.BitmapExponent, b.BitmapRatio)
|
||||
b.BitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1))
|
||||
b.bitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1))
|
||||
profileOffset := getZipfOffset(b.ProfileIDRange, b.ProfileExponent, b.ProfileRatio)
|
||||
b.ProfileRng = rand.NewZipf(rnd, b.ProfileExponent, profileOffset, uint64(b.ProfileIDRange-1))
|
||||
b.profileRng = rand.NewZipf(rnd, b.ProfileExponent, profileOffset, uint64(b.ProfileIDRange-1))
|
||||
|
||||
b.BitmapPerm = NewPermutationGenerator(b.BitmapIDRange, b.Seed)
|
||||
b.ProfilePerm = NewPermutationGenerator(b.ProfileIDRange, b.Seed+1)
|
||||
b.bitmapPerm = NewPermutationGenerator(b.BitmapIDRange, b.Seed)
|
||||
b.profilePerm = NewPermutationGenerator(b.ProfileIDRange, b.Seed+1)
|
||||
|
||||
return b.HasClient.Init(hosts, agentNum)
|
||||
}
|
||||
|
|
@ -145,11 +145,11 @@ func (b *ZipfSetBits) Run(ctx context.Context, agentNum int) map[string]interfac
|
|||
var start time.Time
|
||||
for n := 0; n < b.Iterations; n++ {
|
||||
// generate IDs from Zipf distribution
|
||||
bitmapIDOriginal := b.BitmapRng.Uint64()
|
||||
profIDOriginal := b.ProfileRng.Uint64()
|
||||
bitmapIDOriginal := b.bitmapRng.Uint64()
|
||||
profIDOriginal := b.profileRng.Uint64()
|
||||
// permute IDs randomly, but repeatably
|
||||
bitmapID := b.BitmapPerm.Next(int64(bitmapIDOriginal))
|
||||
profID := b.ProfilePerm.Next(int64(profIDOriginal))
|
||||
bitmapID := b.bitmapPerm.Next(int64(bitmapIDOriginal))
|
||||
profID := b.profilePerm.Next(int64(profIDOriginal))
|
||||
|
||||
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+int64(bitmapID), b.BaseProfileID+int64(profID))
|
||||
start = time.Now()
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,7 @@ type BagentCommand struct {
|
|||
AgentNum int `json:"agent-num"`
|
||||
|
||||
// Enable pretty printing of results, for human consumption.
|
||||
HumanReadable bool
|
||||
HumanReadable bool `json:"human-readable"`
|
||||
|
||||
// Slice of pilosa hosts to run the Benchmarks against.
|
||||
Hosts []string `json:"hosts"`
|
||||
|
|
@ -1284,8 +1284,8 @@ func (cmd *BagentCommand) Run(ctx context.Context) error {
|
|||
res := sbm.Run(ctx, cmd.AgentNum)
|
||||
res["metadata"] = cmd
|
||||
enc := json.NewEncoder(cmd.Stdout)
|
||||
enc.SetIndent("", " ")
|
||||
if cmd.HumanReadable {
|
||||
enc.SetIndent("", " ")
|
||||
res = bench.Prettify(res)
|
||||
}
|
||||
err = enc.Encode(res)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue