diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index 23d2f79eb..1c592cc21 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -1,4 +1,4 @@ -name: codspeed +name: Performance Testing with CodSpeed 🐇 on: push: @@ -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 diff --git a/tests/core/test_connector_sql.py b/tests/core/test_connector_sql.py index 75267451a..b4452d961 100644 --- a/tests/core/test_connector_sql.py +++ b/tests/core/test_connector_sql.py @@ -20,6 +20,8 @@ from singer_sdk.exceptions import ConfigValidationError if t.TYPE_CHECKING: + from pathlib import Path + from sqlalchemy.engine import Engine @@ -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)