| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package bench |
| 6 |
|
| 7 |
import "testing" |
| 8 |
|
| 9 |
func BenchmarkReferences(b *testing.B) { |
| 10 |
tests := []struct { |
| 11 |
repo string |
| 12 |
file string |
| 13 |
regexp string |
| 14 |
}{ |
| 15 |
{"google-cloud-go", "httpreplay/httpreplay.go", `func (NewRecorder)`}, |
| 16 |
{"istio", "pkg/config/model.go", "type (Meta)"}, |
| 17 |
{"kubernetes", "pkg/controller/lookup_cache.go", "type (objectWithMeta)"}, |
| 18 |
{"kuma", "pkg/events/interfaces.go", "type (Event)"}, |
| 19 |
{"pkgsite", "internal/log/log.go", "func (Infof)"}, |
| 20 |
{"starlark", "syntax/syntax.go", "type (Ident)"}, |
| 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.References(loc) |
| 33 |
b.ResetTimer() |
| 34 |
|
| 35 |
if stopAndRecord := startProfileIfSupported(b, env, qualifiedName(test.repo, "references")); stopAndRecord != nil { |
| 36 |
defer stopAndRecord() |
| 37 |
} |
| 38 |
|
| 39 |
for b.Loop() { |
| 40 |
env.References(loc) |
| 41 |
} |
| 42 |
}) |
| 43 |
} |
| 44 |
} |