From bdd25e3000fb077256547d5cce21e7ad1d91cf1e Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Fri, 2 Feb 2024 15:28:13 -0800 Subject: [PATCH] uncomment all tests and randomize seed --- bench_test.go | 37 +++++++++++++++++-------------------- go.mod | 2 ++ go.sum | 4 ++++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bench_test.go b/bench_test.go index 761bd42..b091bab 100644 --- a/bench_test.go +++ b/bench_test.go @@ -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)) }) } @@ -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{ @@ -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() } @@ -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() } diff --git a/go.mod b/go.mod index db3e3e9..34ccc15 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 817f553..9c278cf 100644 --- a/go.sum +++ b/go.sum @@ -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=