Skip to content

Commit

Permalink
uncomment all tests and randomize seed
Browse files Browse the repository at this point in the history
  • Loading branch information
sean- committed Feb 2, 2024
1 parent a99d048 commit bdd25e3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
37 changes: 17 additions & 20 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ import (
)

const (
minTime = 0 * time.Nanosecond
maxTime = 10 * time.Second
randSeed = 42
minTime = 1 * time.Nanosecond
maxTime = 10 * time.Second
)

var randSeed int64 = rand.Int63()

func randDuration(f *faker.Faker, min, max time.Duration) time.Duration {
i := f.IntBetween(int(min), int(max))
return time.Duration(i) * time.Nanosecond
return time.Duration(i)
}

func Benchmark_CircLLHistDuration(b *testing.B) {
h1 := circonusllhist.New()
f := faker.NewWithSeed(rand.NewSource(randSeed))

b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
h1.RecordDuration(randDuration(&f, minTime, maxTime))
}
b.Run("CircLLHistDuration", func(pb *testing.B) {
h1.RecordDuration(randDuration(&f, minTime, maxTime))
})
}

Expand Down Expand Up @@ -118,17 +117,15 @@ func Benchmark_CircLLHistQuantile(b *testing.B) {
})
}

// func Benchmark_CircLLHistDurationNoLookup(b *testing.B) {
// h1 := circonusllhist.NewNoLocks()
// f := faker.NewWithSeed(rand.NewSource(randSeed))
func Benchmark_CircLLHistDurationNoLookup(b *testing.B) {
h1 := circonusllhist.NewNoLocks()
f := faker.NewWithSeed(rand.NewSource(randSeed))

// b.RunParallel(func(pb *testing.PB) {
// for pb.Next() {
// d := randDuration(&f, minTime, maxTime)
// h1.RecordDuration(d)
// }
// })
// }
b.Run("CircLLHistDurationNoLookup", func(pb *testing.B) {
d := randDuration(&f, minTime, maxTime)
h1.RecordDuration(d)
})
}

func Benchmark_PromDuration(b *testing.B) {
h1 := prometheus.NewHistogram(prometheus.HistogramOpts{
Expand Down Expand Up @@ -157,8 +154,8 @@ func Benchmark_PromApproxSum(b *testing.B) {
}
})

m := &prometheusgo.Metric{}
b.Run("SampleSum", func(b *testing.B) {
m := &prometheusgo.Metric{}
if err := h1.Write(m); err != nil {
_ = err // b.Skip()
}
Expand All @@ -182,8 +179,8 @@ func Benchmark_PromApproxCount(b *testing.B) {
}
})

m := &prometheusgo.Metric{}
b.Run("SampleCount", func(b *testing.B) {
m := &prometheusgo.Metric{}
if err := h1.Write(m); err != nil {
_ = err // b.Skip()
}
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ require (
golang.org/x/sys v0.11.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

replace github.com/jaswdr/faker v1.19.1 => github.com/sean-/faker v0.0.0-20231230002109-081f14dffd4c
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+Pymzi
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
github.com/sean-/faker v0.0.0-20231228001344-32d683a58f9f h1:48b1RkzFMOSPHeBVdHYN2hTij7G2+cAMlfdLcTXuS2A=
github.com/sean-/faker v0.0.0-20231228001344-32d683a58f9f/go.mod h1:Gi85R6arFFwvWs4oCDz6qllpPAxw/2rc/JFMQdYkO6Q=
github.com/sean-/faker v0.0.0-20231230002109-081f14dffd4c h1:FpaJkKv3hWFoewE75eYtFShCL7Gb1lkHAQChJzYL0Wo=
github.com/sean-/faker v0.0.0-20231230002109-081f14dffd4c/go.mod h1:Gi85R6arFFwvWs4oCDz6qllpPAxw/2rc/JFMQdYkO6Q=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down

0 comments on commit bdd25e3

Please sign in to comment.