Skip to content

Commit

Permalink
Update sqlglot to V2 (#380)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AmirHesamSH authored Feb 4, 2025
1 parent 15a82c9 commit 727a0aa
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions pyperformance/data-files/benchmarks/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ spectral_norm <local>
sphinx <local>
sqlalchemy_declarative <local>
sqlalchemy_imperative <local>
sqlglot <local>
sqlglot_parse <local:sqlglot>
sqlglot_transpile <local:sqlglot>
sqlglot_optimize <local:sqlglot>
sqlglot_v2 <local>
sqlglot_v2_parse <local:sqlglot_v2>
sqlglot_v2_transpile <local:sqlglot_v2>
sqlglot_v2_optimize <local:sqlglot_v2>
sqlite_synth <local>
sympy <local>
telco <local>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tool.pyperformance]
name = "sqlglot_optimize"
name = "sqlglot_v2_optimize"
extra_opts = ["optimize"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tool.pyperformance]
name = "sqlglot_parse"
name = "sqlglot_v2_parse"
extra_opts = ["parse"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tool.pyperformance]
name = "sqlglot_transpile"
name = "sqlglot_v2_transpile"
extra_opts = ["transpile"]
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = "pyperformance_bm_sqlglot"
name = "pyperformance_bm_sqlglot_v2"
requires-python = ">=3.7"
dependencies = [
"pyperf",
"sqlglot",
"sqlglot_v2",
]
urls = {repository = "https://github.com/python/pyperformance"}
dynamic = ["version"]

[tool.pyperformance]
name = "sqlglot"
name = "sqlglot_v2"
extra_opts = ["normalize"]
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def bench_optimize(loops):

def bench_normalize(loops):
elapsed = 0
conjunction = parse_one("(A AND B) OR (C AND D) OR (E AND F) OR (G AND H)")
for _ in range(loops):
conjunction = parse_one("(A AND B) OR (C AND D) OR (E AND F) OR (G AND H)")
t0 = pyperf.perf_counter()
normalize.normalize(conjunction)
elapsed += pyperf.perf_counter() - t0
Expand Down Expand Up @@ -186,9 +186,9 @@ def add_parser_args(parser):

if __name__ == "__main__":
runner = pyperf.Runner(add_cmdline_args=add_cmdline_args)
runner.metadata['description'] = "SQLGlot benchmark"
runner.metadata['description'] = "SQLGlot V2 benchmark"
add_parser_args(runner.argparser)
args = runner.parse_args()
benchmark = args.benchmark

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

0 comments on commit 727a0aa

Please sign in to comment.