Debian Codegraph @

gopls/internal/test/integration/bench/workspace_symbols_test.go

raw symbols SCIP
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 "time"
12 )
13
14 var symbolQuery = flag.String("symbol_query", "test", "symbol query to use in benchmark")
15
16 // BenchmarkWorkspaceSymbols benchmarks the time to execute a workspace symbols
17 // request (controlled by the -symbol_query flag).
18 func BenchmarkWorkspaceSymbols(b *testing.B) {
19 for name := range repos {
20 b.Run(name, func(b *testing.B) {
21 env := getRepo(b, name).sharedEnv(b)
22 start := time.Now()
23 symbols := env.Symbol(*symbolQuery) // warm the cache
24
25 if testing.Verbose() {
26 fmt.Printf("Results (after %s):\n", time.Since(start))
27 for i, symbol := range symbols {
28 fmt.Printf("\t%d. %s (%s)\n", i, symbol.Name, symbol.ContainerName)
29 }
30 }
31
32 b.ResetTimer()
33
34 if stopAndRecord := startProfileIfSupported(b, env, qualifiedName(name, "workspaceSymbols")); stopAndRecord != nil {
35 defer stopAndRecord()
36 }
37
38 for b.Loop() {
39 env.Symbol(*symbolQuery)
40 }
41 })
42 }
43 }