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

Function BenchmarkMariaDB_ForSystemTime

pkg/sql/parser/mariadb_bench_test.go:82–137  ·  view source on GitHub ↗

BenchmarkMariaDB_ForSystemTime benchmarks MariaDB temporal table query parsing.

(b *testing.B)

Source from the content-addressed store, hash-verified

80
81// BenchmarkMariaDB_ForSystemTime benchmarks MariaDB temporal table query parsing.
82func BenchmarkMariaDB_ForSystemTime(b *testing.B) {
83 benchmarks := []struct {
84 name string
85 sql string
86 }{
87 {
88 name: "as_of_timestamp",
89 sql: "SELECT * FROM t FOR SYSTEM_TIME AS OF TIMESTAMP '2024-01-01 00:00:00'",
90 },
91 {
92 name: "all",
93 sql: "SELECT id, name FROM orders FOR SYSTEM_TIME ALL",
94 },
95 {
96 name: "between",
97 sql: "SELECT * FROM t FOR SYSTEM_TIME BETWEEN TIMESTAMP '2023-01-01' AND TIMESTAMP '2023-12-31'",
98 },
99 {
100 name: "from_to",
101 sql: "SELECT * FROM t FOR SYSTEM_TIME FROM TIMESTAMP '2023-01-01' TO TIMESTAMP '2024-01-01'",
102 },
103 {
104 name: "join_with_system_time",
105 sql: `SELECT o.id, h.status
106 FROM orders o
107 JOIN order_history h FOR SYSTEM_TIME AS OF TIMESTAMP '2024-01-01'
108 ON o.id = h.order_id`,
109 },
110 }
111
112 for _, bm := range benchmarks {
113 bm := bm
114 b.Run(bm.name, func(b *testing.B) {
115 tkz := tokenizer.GetTokenizer()
116 defer tokenizer.PutTokenizer(tkz)
117
118 tokens, err := tkz.Tokenize([]byte(bm.sql))
119 if err != nil {
120 b.Fatalf("Tokenize error: %v", err)
121 }
122
123 b.ResetTimer()
124 b.ReportAllocs()
125
126 for i := 0; i < b.N; i++ {
127 p := parser.NewParser(parser.WithDialect(string(keywords.DialectMariaDB)))
128 result, err := p.ParseFromModelTokens(tokens)
129 if err != nil {
130 b.Fatalf("Parse error: %v", err)
131 }
132 ast.ReleaseAST(result)
133 p.Release()
134 }
135 })
136 }
137}
138
139// BenchmarkMariaDB_ConnectBy benchmarks MariaDB CONNECT BY hierarchical query parsing.

Callers

nothing calls this directly

Calls 10

ParseFromModelTokensMethod · 0.95
ReleaseMethod · 0.95
GetTokenizerFunction · 0.92
PutTokenizerFunction · 0.92
NewParserFunction · 0.92
WithDialectFunction · 0.92
ReleaseASTFunction · 0.92
RunMethod · 0.80
TokenizeMethod · 0.80
FatalfMethod · 0.65

Tested by

no test coverage detected