| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package bench |
| 6 |
|
| 7 |
import "testing" |
| 8 |
|
| 9 |
func BenchmarkImplementations(b *testing.B) { |
| 10 |
tests := []struct { |
| 11 |
repo string |
| 12 |
file string |
| 13 |
regexp string |
| 14 |
}{ |
| 15 |
{"google-cloud-go", "httpreplay/httpreplay.go", `type (Recorder)`}, |
| 16 |
{"istio", "pkg/config/mesh/watcher.go", `type (Watcher)`}, |
| 17 |
{"kubernetes", "pkg/controller/lookup_cache.go", `objectWithMeta`}, |
| 18 |
{"kuma", "api/generic/insights.go", `type (Insight)`}, |
| 19 |
{"pkgsite", "internal/datasource.go", `type (DataSource)`}, |
| 20 |
{"starlark", "syntax/syntax.go", `type (Expr)`}, |
| 21 |
{"tools", "internal/lsp/source/view.go", `type (Snapshot)`}, |
| 22 |
} |
| 23 |
|
| 24 |
for _, test := range tests { |
| 25 |
b.Run(test.repo, func(b *testing.B) { |
| 26 |
env := getRepo(b, test.repo).sharedEnv(b) |
| 27 |
env.OpenFile(test.file) |
| 28 |
defer closeBuffer(b, env, test.file) |
| 29 |
|
| 30 |
loc := env.RegexpSearch(test.file, test.regexp) |
| 31 |
env.AfterChange() |
| 32 |
env.Implementations(loc) |
| 33 |
b.ResetTimer() |
| 34 |
|
| 35 |
if stopAndRecord := startProfileIfSupported(b, env, qualifiedName(test.repo, "implementations")); stopAndRecord != nil { |
| 36 |
defer stopAndRecord() |
| 37 |
} |
| 38 |
|
| 39 |
for b.Loop() { |
| 40 |
env.Implementations(loc) |
| 41 |
} |
| 42 |
}) |
| 43 |
} |
| 44 |
} |