Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add benchmark for SQL tap discovery #2794

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: codspeed
name: Performance Testing with CodSpeed 🐇

on:
push:
Expand All @@ -24,6 +24,13 @@ on:
# performance analysis in order to generate initial data.
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
FORCE_COLOR: "1"

jobs:
benchmarks:
runs-on: ubuntu-latest
Expand Down
41 changes: 41 additions & 0 deletions tests/core/test_connector_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from singer_sdk.exceptions import ConfigValidationError

if t.TYPE_CHECKING:
from pathlib import Path

from sqlalchemy.engine import Engine


Expand Down Expand Up @@ -688,3 +690,42 @@ def handle_raw_string(self, schema):
}
result = json_schema_to_sql.to_sql_type(image_type)
assert isinstance(result, sa.types.LargeBinary)


def test_bench_discovery(benchmark, tmp_path: Path):
def _discover_catalog(connector):
connector.discover_catalog_entries()

number_of_tables = 250
number_of_views = 250
number_of_columns = 10
db_path = tmp_path / "foo.db"
engine = sa.create_engine(f"sqlite:///{db_path}")

columns_fragment = ",".join(f"col_{i} VARCHAR" for i in range(number_of_columns))

# Seed a large number of tables
table_ddl = f"""
CREATE TABLE table_{{n}} (
id INTEGER NOT NULL,
{columns_fragment},
PRIMARY KEY (id)
);
"""

# Seed a large number of views
view_ddl = """
CREATE VIEW view_{n} AS
SELECT * FROM table_{n};
"""

with engine.connect() as conn:
for i in range(number_of_tables):
conn.execute(sa.text(table_ddl.format(n=i)))

for i in range(number_of_views):
conn.execute(sa.text(view_ddl.format(n=i)))

connector = SQLConnector(config={"sqlalchemy_url": f"sqlite:///{db_path}"})

benchmark(_discover_catalog, connector)
Loading