Skip to content

Commit

Permalink
internal/regtest/bench: fix BenchmarkRename and add more benchmark te…
Browse files Browse the repository at this point in the history
…sts for gopls

Change-Id: I8863f3f5b5a50b92a3e844b4fec1902bda1061ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/461802
Reviewed-by: Robert Findley <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Dylan Le <[email protected]>
  • Loading branch information
Dung Le committed Jan 12, 2023
1 parent 2be1a9a commit d19e3d1
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion gopls/internal/regtest/bench/editor_features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,37 @@ func BenchmarkRename(b *testing.B) {

b.ResetTimer()

for i := 0; i < b.N; i++ {
for i := 1; i < b.N; i++ {
pos := env.RegexpSearch("internal/imports/mod.go", "gopathwalk")
newName := fmt.Sprintf("%s%d", "gopathwalk", i)
env.Rename("internal/imports/mod.go", pos, newName)
}
}

func BenchmarkFindAllImplementations(b *testing.B) {
env := benchmarkEnv(b)

env.OpenFile("internal/imports/mod.go")
pos := env.RegexpSearch("internal/imports/mod.go", "initAllMods")
env.Await(env.DoneWithOpen())

b.ResetTimer()

for i := 0; i < b.N; i++ {
env.Implementations("internal/imports/mod.go", pos)
}
}

func BenchmarkHover(b *testing.B) {
env := benchmarkEnv(b)

env.OpenFile("internal/imports/mod.go")
pos := env.RegexpSearch("internal/imports/mod.go", "bytes")
env.Await(env.DoneWithOpen())

b.ResetTimer()

for i := 0; i < b.N; i++ {
env.Hover("internal/imports/mod.go", pos)
}
}

0 comments on commit d19e3d1

Please sign in to comment.