diff options
author | Robert Findley <rfindley@google.com> | 2023-02-16 16:49:37 -0500 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2023-02-17 17:57:06 +0000 |
commit | 3102dad5faf9b21d36f1e58748b62515ef1ee194 (patch) | |
tree | 85601fdad8e72bc92d7af307dc3e2769affa7d31 | |
parent | d9c6b88a966c8531d892128acd7779c889e6e823 (diff) | |
download | golang-x-tools-3102dad5faf9b21d36f1e58748b62515ef1ee194.tar.gz |
gopls/internal/regtest/bench: move benchmarks into separate files
For discoverability, and in preparation for adding more benchmarks, move
benchmarks into separate files organized by operation. Also rename some
benchmark functions to match their LSP operation. No other changes.
Change-Id: Ic8743c4a5fef517084b08204d3c8d032c6e14b44
Reviewed-on: https://go-review.googlesource.com/c/tools/+/468878
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r-- | gopls/internal/regtest/bench/definition_test.go | 22 | ||||
-rw-r--r-- | gopls/internal/regtest/bench/editor_features_test.go | 83 | ||||
-rw-r--r-- | gopls/internal/regtest/bench/hover_test.go | 23 | ||||
-rw-r--r-- | gopls/internal/regtest/bench/implementations_test.go | 21 | ||||
-rw-r--r-- | gopls/internal/regtest/bench/references_test.go | 22 | ||||
-rw-r--r-- | gopls/internal/regtest/bench/rename_test.go | 25 |
6 files changed, 113 insertions, 83 deletions
diff --git a/gopls/internal/regtest/bench/definition_test.go b/gopls/internal/regtest/bench/definition_test.go new file mode 100644 index 000000000..20b75de73 --- /dev/null +++ b/gopls/internal/regtest/bench/definition_test.go @@ -0,0 +1,22 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bench + +import "testing" + +func BenchmarkGoToDefinition(b *testing.B) { + env := sharedEnv(b) + + env.OpenFile("internal/imports/mod.go") + loc := env.RegexpSearch("internal/imports/mod.go", "ModuleJSON") + env.GoToDefinition(loc) + env.Await(env.DoneWithOpen()) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + env.GoToDefinition(loc) + } +} diff --git a/gopls/internal/regtest/bench/editor_features_test.go b/gopls/internal/regtest/bench/editor_features_test.go deleted file mode 100644 index f27132c45..000000000 --- a/gopls/internal/regtest/bench/editor_features_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bench - -import ( - "fmt" - "testing" -) - -func BenchmarkGoToDefinition(b *testing.B) { - env := sharedEnv(b) - - env.OpenFile("internal/imports/mod.go") - loc := env.RegexpSearch("internal/imports/mod.go", "ModuleJSON") - env.GoToDefinition(loc) - env.Await(env.DoneWithOpen()) - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - env.GoToDefinition(loc) - } -} - -func BenchmarkFindAllReferences(b *testing.B) { - env := sharedEnv(b) - - env.OpenFile("internal/imports/mod.go") - loc := env.RegexpSearch("internal/imports/mod.go", "gopathwalk") - env.References(loc) - env.Await(env.DoneWithOpen()) - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - env.References(loc) - } -} - -func BenchmarkRename(b *testing.B) { - env := sharedEnv(b) - - env.OpenFile("internal/imports/mod.go") - env.Await(env.DoneWithOpen()) - - b.ResetTimer() - - for i := 1; i < b.N; i++ { - loc := env.RegexpSearch("internal/imports/mod.go", "gopathwalk") - newName := fmt.Sprintf("%s%d", "gopathwalk", i) - env.Rename(loc, newName) - } -} - -func BenchmarkFindAllImplementations(b *testing.B) { - env := sharedEnv(b) - - env.OpenFile("internal/imports/mod.go") - loc := env.RegexpSearch("internal/imports/mod.go", "initAllMods") - env.Await(env.DoneWithOpen()) - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - env.Implementations(loc) - } -} - -func BenchmarkHover(b *testing.B) { - env := sharedEnv(b) - - env.OpenFile("internal/imports/mod.go") - loc := env.RegexpSearch("internal/imports/mod.go", "bytes") - env.Await(env.DoneWithOpen()) - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - env.Hover(loc) - } -} diff --git a/gopls/internal/regtest/bench/hover_test.go b/gopls/internal/regtest/bench/hover_test.go new file mode 100644 index 000000000..78fdc930a --- /dev/null +++ b/gopls/internal/regtest/bench/hover_test.go @@ -0,0 +1,23 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bench + +import ( + "testing" +) + +func BenchmarkHover(b *testing.B) { + env := sharedEnv(b) + + env.OpenFile("internal/imports/mod.go") + loc := env.RegexpSearch("internal/imports/mod.go", "bytes") + env.Await(env.DoneWithOpen()) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + env.Hover(loc) + } +} diff --git a/gopls/internal/regtest/bench/implementations_test.go b/gopls/internal/regtest/bench/implementations_test.go new file mode 100644 index 000000000..610a2d28c --- /dev/null +++ b/gopls/internal/regtest/bench/implementations_test.go @@ -0,0 +1,21 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bench + +import "testing" + +func BenchmarkFindAllImplementations(b *testing.B) { + env := sharedEnv(b) + + env.OpenFile("internal/imports/mod.go") + loc := env.RegexpSearch("internal/imports/mod.go", "initAllMods") + env.Await(env.DoneWithOpen()) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + env.Implementations(loc) + } +} diff --git a/gopls/internal/regtest/bench/references_test.go b/gopls/internal/regtest/bench/references_test.go new file mode 100644 index 000000000..e5f1f63df --- /dev/null +++ b/gopls/internal/regtest/bench/references_test.go @@ -0,0 +1,22 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bench + +import "testing" + +func BenchmarkReferences(b *testing.B) { + env := sharedEnv(b) + + env.OpenFile("internal/imports/mod.go") + loc := env.RegexpSearch("internal/imports/mod.go", "gopathwalk") + env.References(loc) + env.Await(env.DoneWithOpen()) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + env.References(loc) + } +} diff --git a/gopls/internal/regtest/bench/rename_test.go b/gopls/internal/regtest/bench/rename_test.go new file mode 100644 index 000000000..e6db663a4 --- /dev/null +++ b/gopls/internal/regtest/bench/rename_test.go @@ -0,0 +1,25 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bench + +import ( + "fmt" + "testing" +) + +func BenchmarkRename(b *testing.B) { + env := sharedEnv(b) + + env.OpenFile("internal/imports/mod.go") + env.Await(env.DoneWithOpen()) + + b.ResetTimer() + + for i := 1; i < b.N; i++ { + loc := env.RegexpSearch("internal/imports/mod.go", "gopathwalk") + newName := fmt.Sprintf("%s%d", "gopathwalk", i) + env.Rename(loc, newName) + } +} |