From 278f416d08028bd175e1d6433739461f2168f4e2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 11 Jun 2024 18:34:56 +0200 Subject: Adding upstream version 25.0.3. Signed-off-by: Daniel Baumann --- benchmarks/bench.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'benchmarks/bench.py') diff --git a/benchmarks/bench.py b/benchmarks/bench.py index 917266d..51872db 100644 --- a/benchmarks/bench.py +++ b/benchmarks/bench.py @@ -1,5 +1,7 @@ import collections.abc +from benchmarks.helpers import ascii_table + # moz_sql_parser 3.10 compatibility collections.Iterable = collections.abc.Iterable import timeit @@ -188,11 +190,6 @@ def sqlfluff_parse(sql): sqlfluff.parse(sql) -def border(columns): - columns = " | ".join(columns) - return f"| {columns} |" - - def diff(row, column): if column == "Query": return "" @@ -223,19 +220,11 @@ for name, sql in {"tpch": tpch, "short": short, "long": long, "crazy": crazy}.it print(e) row[lib] = "error" -columns = ["Query"] + libs -widths = {column: max(len(column), 15) for column in columns} - -lines = [border(column.rjust(width) for column, width in widths.items())] -lines.append(border(str("-" * width) for width in widths.values())) - -for i, row in enumerate(table): - lines.append( - border( - (str(row[column])[0:7] + diff(row, column)).rjust(width)[0:width] - for column, width in widths.items() - ) +print( + ascii_table( + [ + {k: v if v == "Query" else str(row[k])[0:7] + diff(row, k) for k, v in row.items()} + for row in table + ] ) - -for line in lines: - print(line) +) -- cgit v1.2.3