From b05ca5c36ebf99b7767c69b998c1c2e97c6a6d64 Mon Sep 17 00:00:00 2001 From: naivewong <867245430@qq.com> Date: Fri, 14 Jun 2019 20:30:49 +0800 Subject: [PATCH] fix two benchmarks (#631) * fix two benchmarks Signed-off-by: naivewong <867245430@qq.com> --- compact_test.go | 8 ++++---- head_test.go | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/compact_test.go b/compact_test.go index 545dedbfcd..cbf331f9c2 100644 --- a/compact_test.go +++ b/compact_test.go @@ -800,11 +800,11 @@ func BenchmarkCompaction(b *testing.B) { compactionType: "normal", }, { - ranges: [][2]int64{{0, 10000}, {20000, 30000}, {40000, 50000}, {60000, 70000}}, + ranges: [][2]int64{{0, 2000}, {3000, 5000}, {6000, 8000}, {9000, 11000}}, compactionType: "normal", }, { - ranges: [][2]int64{{0, 100000}, {200000, 300000}, {400000, 500000}, {600000, 700000}}, + ranges: [][2]int64{{0, 5000}, {6000, 11000}, {12000, 17000}, {18000, 23000}}, compactionType: "normal", }, // 40% overlaps. @@ -817,11 +817,11 @@ func BenchmarkCompaction(b *testing.B) { compactionType: "vertical", }, { - ranges: [][2]int64{{0, 10000}, {6000, 16000}, {12000, 22000}, {18000, 28000}}, + ranges: [][2]int64{{0, 2000}, {1200, 3200}, {2400, 4400}, {3600, 5600}}, compactionType: "vertical", }, { - ranges: [][2]int64{{0, 100000}, {60000, 160000}, {120000, 220000}, {180000, 280000}}, + ranges: [][2]int64{{0, 5000}, {3000, 8000}, {6000, 11000}, {9000, 14000}}, compactionType: "vertical", }, } diff --git a/head_test.go b/head_test.go index 7f3579b549..30ff27dbfe 100644 --- a/head_test.go +++ b/head_test.go @@ -19,7 +19,6 @@ import ( "math/rand" "os" "path" - "path/filepath" "sort" "testing" @@ -34,8 +33,7 @@ import ( ) func BenchmarkCreateSeries(b *testing.B) { - lbls, err := labels.ReadLabels(filepath.Join("testdata", "20kseries.json"), b.N) - testutil.Ok(b, err) + series := genSeries(b.N, 10, 0, 0) h, err := NewHead(nil, nil, nil, 10000) testutil.Ok(b, err) @@ -44,8 +42,8 @@ func BenchmarkCreateSeries(b *testing.B) { b.ReportAllocs() b.ResetTimer() - for _, l := range lbls { - h.getOrCreate(l.Hash(), l) + for _, s := range series { + h.getOrCreate(s.Labels().Hash(), s.Labels()) } }