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

Function BenchmarkParseError

pkg/sql/parser/pipeline_bench_test.go:69–100  ·  view source on GitHub ↗

BenchmarkParseError benchmarks error handling performance for invalid SQL.

(b *testing.B)

Source from the content-addressed store, hash-verified

67
68// BenchmarkParseError benchmarks error handling performance for invalid SQL.
69func BenchmarkParseError(b *testing.B) {
70 queries := map[string]string{
71 "missing_from": "SELECT * WHERE x = 1",
72 "missing_table": "SELECT * FROM",
73 "bad_syntax": "SELECTT * FROM users",
74 "incomplete_insert": "INSERT INTO users",
75 "trailing_comma": "SELECT a, b, FROM t",
76 "unmatched_paren": "SELECT (a + b FROM t",
77 "empty": "",
78 }
79
80 for name, sql := range queries {
81 b.Run(name, func(b *testing.B) {
82 b.ReportAllocs()
83 sqlBytes := []byte(sql)
84
85 b.ResetTimer()
86 for i := 0; i < b.N; i++ {
87 tkz := tokenizer.GetTokenizer()
88 tokens, err := tkz.Tokenize(sqlBytes)
89 tokenizer.PutTokenizer(tkz)
90 if err != nil {
91 continue // tokenizer error path
92 }
93
94 p := NewParser()
95 _, _ = p.ParseFromModelTokensWithPositions(tokens)
96 p.Release()
97 }
98 })
99 }
100}

Callers

nothing calls this directly

Calls 7

ReleaseMethod · 0.95
GetTokenizerFunction · 0.92
PutTokenizerFunction · 0.92
RunMethod · 0.80
TokenizeMethod · 0.80
NewParserFunction · 0.70

Tested by

no test coverage detected