gopls/internal/regtest/bench: add a proper benchmark for initial load
Add a new 'gopls.mem_stats' command, and use it to implement benchmark
metrics for memory usage, integrated with the initial workspace load
test. Delete the old mem_test.go.
For golang/go#57987
Change-Id: If721e77193f63ebc8532c165595f7ce99f862fd3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/468935
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
diff --git a/gopls/internal/lsp/source/api_json.go b/gopls/internal/lsp/source/api_json.go
index 3fa7ca2..e655eb0 100755
--- a/gopls/internal/lsp/source/api_json.go
+++ b/gopls/internal/lsp/source/api_json.go
@@ -728,6 +728,12 @@
ResultDoc: "{\n\t// Packages is a list of packages relative\n\t// to the URIArg passed by the command request.\n\t// In other words, it omits paths that are already\n\t// imported or cannot be imported due to compiler\n\t// restrictions.\n\t\"Packages\": []string,\n}",
},
{
+ Command: "gopls.mem_stats",
+ Title: "fetch memory statistics",
+ Doc: "Call runtime.GC multiple times and return memory statistics as reported by\nruntime.MemStats.\n\nThis command is used for benchmarking, and may change in the future.",
+ ResultDoc: "{\n\t\"HeapAlloc\": uint64,\n\t\"HeapInUse\": uint64,\n}",
+ },
+ {
Command: "gopls.regenerate_cgo",
Title: "Regenerate cgo",
Doc: "Regenerates cgo definitions.",