Skip to content

Commit 28320dc

Browse files
authored
Merge pull request #1718 from cloudflare/bench
Try to reduce benchmark drift
2 parents 18152ba + 1e68413 commit 28320dc

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ coverhtml: test
5959
.PHONY: benchmark
6060
benchmark:
6161
go test \
62-
-timeout=15m \
63-
-count=5 \
62+
-timeout=20m \
63+
-count=10 \
6464
-run=none \
65+
-short \
6566
-bench=. \
6667
-benchmem \
6768
./...

cmd/pint/bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ rule {
156156

157157
b.ResetTimer()
158158
for b.Loop() {
159-
_, _ = checkRules(b.Context(), 10, false, gen, cfg, entries)
159+
_, _ = checkRules(b.Context(), 1, false, gen, cfg, entries)
160160
}
161161
}
162162

internal/promapi/cache_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ func BenchmarkQueryCacheOnlySet(b *testing.B) {
285285
}
286286

287287
func BenchmarkQueryCacheSetGrow(b *testing.B) {
288+
if testing.Short() {
289+
b.SkipNow()
290+
}
291+
288292
const maxSize = 1000
289293
mockErr := errors.New("Fake Error")
290294
cache := newQueryCache(time.Minute, time.Now)
@@ -301,15 +305,22 @@ func BenchmarkQueryCacheSetGrow(b *testing.B) {
301305
}
302306

303307
func BenchmarkQueryCacheGetMiss(b *testing.B) {
304-
cache := newQueryCache(time.Minute, time.Now)
308+
if testing.Short() {
309+
b.SkipNow()
310+
}
305311

312+
cache := newQueryCache(time.Minute, time.Now)
306313
b.ResetTimer()
307314
for n := 0; b.Loop(); n++ {
308315
cache.get(uint64(n), "/foo")
309316
}
310317
}
311318

312319
func BenchmarkQueryCacheGC(b *testing.B) {
320+
if testing.Short() {
321+
b.SkipNow()
322+
}
323+
313324
mockErr := errors.New("Fake Error")
314325

315326
for _, percent := range []uint64{0, 1, 10, 20, 25, 50, 75, 99, 100} {

0 commit comments

Comments
 (0)