Skip to content

Commit 727a0aa

Browse files
authored
Update sqlglot to V2 (#380)
In the current sqlglot normalized, conjunction string would be modified to its normalized form after the first iteration. And for the remaining iterations, normalization function was applied to the normalized form of the original conjunction string. Therefore, the performance of the first iteration would be different to the remaining iterations. This causes unsuitability in performance reports. To fix this issue, we created the V2 version, in which, a new conjunction string is created for every individual iteration.
1 parent 15a82c9 commit 727a0aa

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

pyperformance/data-files/benchmarks/MANIFEST

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ spectral_norm <local>
8383
sphinx <local>
8484
sqlalchemy_declarative <local>
8585
sqlalchemy_imperative <local>
86-
sqlglot <local>
87-
sqlglot_parse <local:sqlglot>
88-
sqlglot_transpile <local:sqlglot>
89-
sqlglot_optimize <local:sqlglot>
86+
sqlglot_v2 <local>
87+
sqlglot_v2_parse <local:sqlglot_v2>
88+
sqlglot_v2_transpile <local:sqlglot_v2>
89+
sqlglot_v2_optimize <local:sqlglot_v2>
9090
sqlite_synth <local>
9191
sympy <local>
9292
telco <local>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[tool.pyperformance]
2-
name = "sqlglot_optimize"
2+
name = "sqlglot_v2_optimize"
33
extra_opts = ["optimize"]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[tool.pyperformance]
2-
name = "sqlglot_parse"
2+
name = "sqlglot_v2_parse"
33
extra_opts = ["parse"]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[tool.pyperformance]
2-
name = "sqlglot_transpile"
2+
name = "sqlglot_v2_transpile"
33
extra_opts = ["transpile"]
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[project]
2-
name = "pyperformance_bm_sqlglot"
2+
name = "pyperformance_bm_sqlglot_v2"
33
requires-python = ">=3.7"
44
dependencies = [
55
"pyperf",
6-
"sqlglot",
6+
"sqlglot_v2",
77
]
88
urls = {repository = "https://github.com/python/pyperformance"}
99
dynamic = ["version"]
1010

1111
[tool.pyperformance]
12-
name = "sqlglot"
12+
name = "sqlglot_v2"
1313
extra_opts = ["normalize"]

pyperformance/data-files/benchmarks/bm_sqlglot/run_benchmark.py renamed to pyperformance/data-files/benchmarks/bm_sqlglot_v2/run_benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def bench_optimize(loops):
156156

157157
def bench_normalize(loops):
158158
elapsed = 0
159-
conjunction = parse_one("(A AND B) OR (C AND D) OR (E AND F) OR (G AND H)")
160159
for _ in range(loops):
160+
conjunction = parse_one("(A AND B) OR (C AND D) OR (E AND F) OR (G AND H)")
161161
t0 = pyperf.perf_counter()
162162
normalize.normalize(conjunction)
163163
elapsed += pyperf.perf_counter() - t0
@@ -186,9 +186,9 @@ def add_parser_args(parser):
186186

187187
if __name__ == "__main__":
188188
runner = pyperf.Runner(add_cmdline_args=add_cmdline_args)
189-
runner.metadata['description'] = "SQLGlot benchmark"
189+
runner.metadata['description'] = "SQLGlot V2 benchmark"
190190
add_parser_args(runner.argparser)
191191
args = runner.parse_args()
192192
benchmark = args.benchmark
193193

194-
runner.bench_time_func(f"sqlglot_{benchmark}", BENCHMARKS[benchmark])
194+
runner.bench_time_func(f"sqlglot_v2_{benchmark}", BENCHMARKS[benchmark])

0 commit comments

Comments
 (0)