diff --git a/Makefile b/Makefile index bdf498162b..2d0a08f8b6 100644 --- a/Makefile +++ b/Makefile @@ -301,6 +301,7 @@ bench-daily: go test -tags intest github.com/pingcap/tidb/pkg/util/rowcodec -run TestBenchDaily -bench Ignore --outfile bench_daily.json go test -tags intest github.com/pingcap/tidb/pkg/util/codec -run TestBenchDaily -bench Ignore --outfile bench_daily.json go test -tags intest github.com/pingcap/tidb/pkg/distsql -run TestBenchDaily -bench Ignore --outfile bench_daily.json + go test -tags intest github.com/pingcap/tidb/pkg/statistics -run TestBenchDaily -bench Ignore --outfile bench_daily.json go test -tags intest github.com/pingcap/tidb/pkg/util/benchdaily -run TestBenchDaily -bench Ignore \ -date `git log -n1 --date=unix --pretty=format:%cd` \ -commit `git log -n1 --pretty=format:%h` \ diff --git a/pkg/statistics/BUILD.bazel b/pkg/statistics/BUILD.bazel index 43903c7480..d6a2cb58b6 100644 --- a/pkg/statistics/BUILD.bazel +++ b/pkg/statistics/BUILD.bazel @@ -62,6 +62,7 @@ go_test( name = "statistics_test", timeout = "short", srcs = [ + "bench_daily_test.go", "builder_test.go", "cmsketch_test.go", "fmsketch_test.go", @@ -76,7 +77,7 @@ go_test( data = glob(["testdata/**"]), embed = [":statistics"], flaky = True, - shard_count = 33, + shard_count = 34, deps = [ "//pkg/config", "//pkg/parser/ast", @@ -90,6 +91,7 @@ go_test( "//pkg/testkit/testmain", "//pkg/testkit/testsetup", "//pkg/types", + "//pkg/util/benchdaily", "//pkg/util/chunk", "//pkg/util/codec", "//pkg/util/collate", diff --git a/pkg/statistics/bench_daily_test.go b/pkg/statistics/bench_daily_test.go new file mode 100644 index 0000000000..a7e8474b15 --- /dev/null +++ b/pkg/statistics/bench_daily_test.go @@ -0,0 +1,27 @@ +// Copyright 2023 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package statistics + +import ( + "testing" + + "github.com/pingcap/tidb/pkg/util/benchdaily" +) + +func TestBenchDaily(*testing.T) { + benchdaily.Run( + BenchmarkBuildHistAndTopN, + ) +} diff --git a/pkg/statistics/builder_test.go b/pkg/statistics/builder_test.go index 8e3256f5ff..ed39d8feff 100644 --- a/pkg/statistics/builder_test.go +++ b/pkg/statistics/builder_test.go @@ -28,9 +28,10 @@ import ( // go test -benchmem -run=^$ -bench ^BenchmarkBuildHistAndTopN$ github.com/pingcap/tidb/pkg/statistics func BenchmarkBuildHistAndTopN(b *testing.B) { ctx := mock.NewContext() - sketch := NewFMSketch(1000) + const cnt = 1000_000 + sketch := NewFMSketch(cnt) data := make([]*SampleItem, 0, 8) - for i := 1; i <= 1000; i++ { + for i := 1; i <= cnt; i++ { d := types.NewIntDatum(int64(i)) err := sketch.InsertValue(ctx.GetSessionVars().StmtCtx, d) require.NoError(b, err)