statistics: add daily bench and improve bench (#48824)

close pingcap/tidb#48699
This commit is contained in:
Weizhen Wang
2023-11-23 15:26:49 +08:00
committed by GitHub
parent 3159e1d5c3
commit 5b8d3deef6
4 changed files with 34 additions and 3 deletions

View File

@ -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` \

View File

@ -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",

View File

@ -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,
)
}

View File

@ -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)