MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / BenchmarkHandler_HoverKeyword

Function BenchmarkHandler_HoverKeyword

pkg/lsp/handler_bench_test.go:47–80  ·  view source on GitHub ↗

BenchmarkHandler_HoverKeyword benchmarks hover on different keywords

(b *testing.B)

Source from the content-addressed store, hash-verified

45
46// BenchmarkHandler_HoverKeyword benchmarks hover on different keywords
47func BenchmarkHandler_HoverKeyword(b *testing.B) {
48 keywords := []struct {
49 name string
50 sql string
51 position Position
52 }{
53 {"SELECT", "SELECT * FROM users", Position{Line: 0, Character: 0}},
54 {"FROM", "SELECT * FROM users", Position{Line: 0, Character: 10}},
55 {"WHERE", "SELECT * FROM users WHERE id = 1", Position{Line: 0, Character: 20}},
56 {"JOIN", "SELECT * FROM users JOIN orders ON users.id = orders.user_id", Position{Line: 0, Character: 20}},
57 {"INSERT", "INSERT INTO users (name) VALUES ('test')", Position{Line: 0, Character: 0}},
58 {"UPDATE", "UPDATE users SET name = 'test' WHERE id = 1", Position{Line: 0, Character: 0}},
59 {"DELETE", "DELETE FROM users WHERE id = 1", Position{Line: 0, Character: 0}},
60 }
61
62 for _, kw := range keywords {
63 b.Run(kw.name, func(b *testing.B) {
64 server := setupTestServer()
65 server.Documents().Open("file:///test.sql", "sql", 1, kw.sql)
66
67 params := TextDocumentPositionParams{
68 TextDocument: TextDocumentIdentifier{URI: "file:///test.sql"},
69 Position: kw.position,
70 }
71 paramsJSON, _ := json.Marshal(params)
72
73 b.ReportAllocs()
74 b.ResetTimer()
75 for i := 0; i < b.N; i++ {
76 _, _ = server.handler.HandleRequest("textDocument/hover", paramsJSON)
77 }
78 })
79 }
80}
81
82// BenchmarkHandler_Completion benchmarks completion operation
83func BenchmarkHandler_Completion(b *testing.B) {

Callers

nothing calls this directly

Calls 5

setupTestServerFunction · 0.85
RunMethod · 0.80
OpenMethod · 0.80
DocumentsMethod · 0.80
HandleRequestMethod · 0.80

Tested by

no test coverage detected