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

Function BenchmarkScanner_ComplexQuery

pkg/sql/security/scanner_bench_test.go:159–184  ·  view source on GitHub ↗

BenchmarkScanner_ComplexQuery benchmarks scanning complex SQL queries

(b *testing.B)

Source from the content-addressed store, hash-verified

157
158// BenchmarkScanner_ComplexQuery benchmarks scanning complex SQL queries
159func BenchmarkScanner_ComplexQuery(b *testing.B) {
160 sql := `
161 SELECT
162 u.id, u.name, u.email,
163 o.order_id, o.total,
164 p.product_name
165 FROM users u
166 LEFT JOIN orders o ON u.id = o.user_id
167 INNER JOIN products p ON o.product_id = p.id
168 WHERE u.active = true
169 AND o.order_date > '2023-01-01'
170 AND p.category IN ('electronics', 'books')
171 ORDER BY o.order_date DESC
172 LIMIT 100
173 `
174 scanner := NewScanner()
175
176 tree := parseSQL(b, sql)
177 defer ast.ReleaseAST(tree)
178
179 b.ReportAllocs()
180 b.ResetTimer()
181 for i := 0; i < b.N; i++ {
182 scanner.Scan(tree)
183 }
184}
185
186// BenchmarkScanner_LargeQuery benchmarks scanning large SQL queries
187func BenchmarkScanner_LargeQuery(b *testing.B) {

Callers

nothing calls this directly

Calls 4

ScanMethod · 0.95
ReleaseASTFunction · 0.92
NewScannerFunction · 0.85
parseSQLFunction · 0.70

Tested by

no test coverage detected