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

Function BenchmarkDocument_GetWordAtPosition

pkg/lsp/handler_bench_test.go:446–468  ·  view source on GitHub ↗

BenchmarkDocument_GetWordAtPosition benchmarks word extraction at position

(b *testing.B)

Source from the content-addressed store, hash-verified

444
445// BenchmarkDocument_GetWordAtPosition benchmarks word extraction at position
446func BenchmarkDocument_GetWordAtPosition(b *testing.B) {
447 doc := &Document{
448 Content: "SELECT id, name, email FROM users WHERE active = true ORDER BY name",
449 Lines: []string{"SELECT id, name, email FROM users WHERE active = true ORDER BY name"},
450 }
451
452 positions := []Position{
453 {Line: 0, Character: 0}, // SELECT
454 {Line: 0, Character: 7}, // id
455 {Line: 0, Character: 28}, // FROM
456 {Line: 0, Character: 33}, // users
457 {Line: 0, Character: 39}, // WHERE
458 {Line: 0, Character: 45}, // active
459 {Line: 0, Character: 61}, // BY
460 }
461
462 b.ReportAllocs()
463 b.ResetTimer()
464 for i := 0; i < b.N; i++ {
465 pos := positions[i%len(positions)]
466 _ = doc.GetWordAtPosition(pos)
467 }
468}
469
470// BenchmarkPositionToOffset benchmarks position to offset conversion
471func BenchmarkPositionToOffset(b *testing.B) {

Callers

nothing calls this directly

Calls 1

GetWordAtPositionMethod · 0.95

Tested by

no test coverage detected