| 1 | // Copyright 2023 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 | // The bench package implements benchmarks for various LSP operations. |
| 6 | // |
| 7 | // Benchmarks check out specific commits of popular and/or exemplary |
| 8 | // repositories, and script an external gopls process via a fake text editor. |
| 9 | // By default, benchmarks run the test executable as gopls (using a special |
| 10 | // "gopls mode" environment variable). A different gopls binary may be used by |
| 11 | // setting the -gopls_path or -gopls_commit flags. |
| 12 | // |
| 13 | // This package is a work in progress. |
| 14 | // |
| 15 | // # Profiling |
| 16 | // |
| 17 | // Benchmark functions run gopls in a separate process, which means the normal |
| 18 | // test flags for profiling aren't useful. Instead the -gopls_cpuprofile, |
| 19 | // -gopls_memprofile, -gopls_allocprofile, -gopls_blockprofile, and |
| 20 | // -gopls_trace flags may be used to pass through profiling to the gopls |
| 21 | // subprocess. |
| 22 | // |
| 23 | // Each of these flags sets a suffix for the respective gopls profile, which is |
| 24 | // named according to the schema <repo>.<operation>.<suffix>. For example, |
| 25 | // setting -gopls_cpuprofile=cpu will result in profiles named tools.iwl.cpu, |
| 26 | // tools.rename.cpu, etc. In some cases, these profiles are for the entire |
| 27 | // gopls subprocess (as in the initial workspace load), whereas in others they |
| 28 | // span only the critical section of the benchmark. It is up to each benchmark |
| 29 | // to implement profiling as appropriate. |
| 30 | // |
| 31 | // # Integration with perf.golang.org |
| 32 | // |
| 33 | // Benchmarks that run with -short are automatically tracked by |
| 34 | // perf.golang.org, at |
| 35 | // https://perf.golang.org/dashboard/?benchmark=all&repository=tools&branch=release-branch.go1.20 |
| 36 | // |
| 37 | // # TODO |
| 38 | // - add more benchmarks, and more repositories |
| 39 | // - fix the perf dashboard to not require the branch= parameter |
| 40 | // - improve this documentation |
| 41 | package bench |