add fine grained stats within benchmarks

This commit is contained in:
jaffee 2016-11-16 10:57:54 -06:00
parent 05a70d5fb2
commit d3714729ac
4 changed files with 57 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import (
"io/ioutil"
"context"
"time"
)
// DiagonalSetBits sets bits with increasing profile id and bitmap id.
@ -66,10 +67,15 @@ func (b *DiagonalSetBits) Run(agentNum int) map[string]interface{} {
results["error"] = fmt.Errorf("No client set for DiagonalSetBits agent: %v", agentNum)
return results
}
s := NewStats()
var start time.Time
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)
start = time.Now()
b.cli.ExecuteQuery(context.TODO(), b.DB, query, true)
s.Add(time.Now().Sub(start))
}
AddToResults(s, results)
return results
}

View file

@ -8,6 +8,7 @@ import (
"io/ioutil"
"context"
"time"
)
// MultiDBSetBits sets bits with increasing profile id and bitmap id.
@ -62,9 +63,14 @@ func (b *MultiDBSetBits) Run(agentNum int) map[string]interface{} {
results["error"] = fmt.Errorf("No client set for MultiDBSetBits agent: %v", agentNum)
return results
}
s := NewStats()
var start time.Time
for n := 0; n < b.Iterations; n++ {
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+n, b.BaseProfileID+n)
start = time.Now()
b.cli.ExecuteQuery(context.TODO(), "multidb"+strconv.Itoa(agentNum), query, true)
s.Add(time.Now().Sub(start))
}
AddToResults(s, results)
return results
}

View file

@ -8,6 +8,7 @@ import (
"context"
"math/rand"
"time"
)
// RandomSetBits sets bits randomly and deterministically based on a seed.
@ -84,11 +85,16 @@ func (b *RandomSetBits) Run(agentNum int) map[string]interface{} {
results["error"] = fmt.Errorf("No client set for RandomSetBits agent: %v", agentNum)
return results
}
s := NewStats()
var start time.Time
for n := 0; n < b.Iterations; n++ {
bitmapID := rng.Int63n(b.BitmapIDRange)
profID := rng.Int63n(b.ProfileIDRange)
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+bitmapID, b.BaseProfileID+profID)
start = time.Now()
b.cli.ExecuteQuery(context.TODO(), b.DB, query, true)
s.Add(time.Now().Sub(start))
}
AddToResults(s, results)
return results
}

39
bench/stats.go Normal file
View file

@ -0,0 +1,39 @@
package bench
import (
"time"
)
type Stats struct {
Min time.Duration
Max time.Duration
Total time.Duration
Num int64
}
func NewStats() *Stats {
return &Stats{
Min: 1<<63 - 1,
}
}
func (s *Stats) Add(td time.Duration) {
s.Num += 1
s.Total += td
if td < s.Min {
s.Min = td
}
if td > s.Max {
s.Max = td
}
}
func (s *Stats) Avg() time.Duration {
return s.Total / time.Duration(s.Num)
}
func AddToResults(s *Stats, results map[string]interface{}) {
results["min"] = s.Min
results["max"] = s.Max
results["avg"] = s.Avg()
}