diff options
Diffstat (limited to 'gopls/internal/regtest/bench/definition_test.go')
-rw-r--r-- | gopls/internal/regtest/bench/definition_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gopls/internal/regtest/bench/definition_test.go b/gopls/internal/regtest/bench/definition_test.go new file mode 100644 index 000000000..a3e68f532 --- /dev/null +++ b/gopls/internal/regtest/bench/definition_test.go @@ -0,0 +1,39 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bench + +import ( + "testing" +) + +func BenchmarkDefinition(b *testing.B) { + tests := []struct { + repo string + file string + regexp string + }{ + {"istio", "pkg/config/model.go", `gogotypes\.(MarshalAny)`}, + {"kubernetes", "pkg/controller/lookup_cache.go", `hashutil\.(DeepHashObject)`}, + {"kuma", "api/generic/insights.go", `proto\.(Message)`}, + {"pkgsite", "internal/log/log.go", `derrors\.(Wrap)`}, + {"starlark", "starlark/eval.go", "prog.compiled.(Encode)"}, + {"tools", "internal/lsp/cache/check.go", `(snapshot)\) buildKey`}, + } + + for _, test := range tests { + b.Run(test.repo, func(b *testing.B) { + env := getRepo(b, test.repo).sharedEnv(b) + env.OpenFile(test.file) + loc := env.RegexpSearch(test.file, test.regexp) + env.Await(env.DoneWithOpen()) + env.GoToDefinition(loc) // pre-warm the query, and open the target file + b.ResetTimer() + + for i := 0; i < b.N; i++ { + env.GoToDefinition(loc) // pre-warm the query + } + }) + } +} |