golang.org/x/tools/gopls@v0.15.3/internal/test/integration/bench/workspace_symbols_test.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package bench 6 7 import ( 8 "flag" 9 "fmt" 10 "testing" 11 ) 12 13 var symbolQuery = flag.String("symbol_query", "test", "symbol query to use in benchmark") 14 15 // BenchmarkWorkspaceSymbols benchmarks the time to execute a workspace symbols 16 // request (controlled by the -symbol_query flag). 17 func BenchmarkWorkspaceSymbols(b *testing.B) { 18 for name := range repos { 19 b.Run(name, func(b *testing.B) { 20 env := getRepo(b, name).sharedEnv(b) 21 symbols := env.Symbol(*symbolQuery) // warm the cache 22 23 if testing.Verbose() { 24 fmt.Println("Results:") 25 for i, symbol := range symbols { 26 fmt.Printf("\t%d. %s (%s)\n", i, symbol.Name, symbol.ContainerName) 27 } 28 } 29 30 b.ResetTimer() 31 32 if stopAndRecord := startProfileIfSupported(b, env, qualifiedName(name, "workspaceSymbols")); stopAndRecord != nil { 33 defer stopAndRecord() 34 } 35 36 for i := 0; i < b.N; i++ { 37 env.Symbol(*symbolQuery) 38 } 39 }) 40 } 41 }