Skip to content

Commit

Permalink
added benchmark for RecordGenerator.insertRR
Browse files Browse the repository at this point in the history
  • Loading branch information
James DeFelice committed Mar 7, 2016
1 parent 1b9aca9 commit 7ca1983
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions records/generator_perf_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package records

import (
"math/rand"
"strconv"
"testing"
)

func BenchmarkInsertRR(b *testing.B) {
const (
clusterSize = 1000
appCount = 5
)
var (
slaves = make([]string, clusterSize)
apps = make([]string, appCount)
rg = &RecordGenerator{
As: rrs{},
SRVs: rrs{},
}
)
for i := 0; i < clusterSize; i++ {
slaves[i] = "slave" + strconv.Itoa(i)
}
for i := 0; i < appCount; i++ {
apps[i] = "app" + strconv.Itoa(i)
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
var (
si = rand.Int31n(clusterSize)
ai = rand.Int31n(appCount)
)
rg.insertRR(apps[ai], slaves[si], "A")
}
}

0 comments on commit 7ca1983

Please sign in to comment.