| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package bench |
| 6 |
|
| 7 |
import ( |
| 8 |
"testing" |
| 9 |
) |
| 10 |
|
| 11 |
func BenchmarkHover(b *testing.B) { |
| 12 |
tests := []struct { |
| 13 |
repo string |
| 14 |
file string |
| 15 |
regexp string |
| 16 |
}{ |
| 17 |
{"google-cloud-go", "httpreplay/httpreplay.go", `proxy\.(ForRecording)`}, |
| 18 |
{"istio", "pkg/config/model.go", `gogotypes\.(MarshalAny)`}, |
| 19 |
{"kubernetes", "pkg/apis/core/types.go", "type (Pod)"}, |
| 20 |
{"kuma", "api/generic/insights.go", `proto\.(Message)`}, |
| 21 |
{"pkgsite", "internal/log/log.go", `derrors\.(Wrap)`}, |
| 22 |
{"starlark", "starlark/eval.go", "prog.compiled.(Encode)"}, |
| 23 |
{"tools", "internal/lsp/cache/check.go", `(snapshot)\) buildKey`}, |
| 24 |
} |
| 25 |
|
| 26 |
for _, test := range tests { |
| 27 |
b.Run(test.repo, func(b *testing.B) { |
| 28 |
env := getRepo(b, test.repo).sharedEnv(b) |
| 29 |
env.OpenFile(test.file) |
| 30 |
defer closeBuffer(b, env, test.file) |
| 31 |
|
| 32 |
loc := env.RegexpSearch(test.file, test.regexp) |
| 33 |
env.AfterChange() |
| 34 |
|
| 35 |
env.Hover(loc) |
| 36 |
b.ResetTimer() |
| 37 |
|
| 38 |
if stopAndRecord := startProfileIfSupported(b, env, qualifiedName(test.repo, "hover")); stopAndRecord != nil { |
| 39 |
defer stopAndRecord() |
| 40 |
} |
| 41 |
|
| 42 |
for b.Loop() { |
| 43 |
env.Hover(loc) |
| 44 |
} |
| 45 |
}) |
| 46 |
} |
| 47 |
} |