Skip to content

Commit

Permalink
test(duckdb): add memtable registration benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jun 21, 2024
1 parent 1839c13 commit 53bf76c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ibis/tests/benchmarks/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import functools
import inspect
import itertools
import math
import os
import string
from operator import attrgetter, itemgetter
Expand Down Expand Up @@ -865,3 +866,21 @@ def test_large_union_construct(benchmark, many_tables):
def test_large_union_compile(benchmark, many_tables):
expr = ibis.union(*many_tables)
assert benchmark(ibis.to_sql, expr) is not None


@pytest.fixture(scope="session")
def lots_of_tables(tmp_path_factory):
duckdb = pytest.importorskip("duckdb")
db = str(tmp_path_factory.mktemp("data") / "lots_of_tables.ddb")
n = 100_000
d = int(math.log10(n))
sql = ";".join(f"CREATE TABLE t{i:0>{d}} (x TINYINT)" for i in range(n))
with duckdb.connect(db) as con:
con.execute(sql)
return ibis.duckdb.connect(db)


def test_memtable_register(lots_of_tables, benchmark):
t = ibis.memtable({"x": [1, 2, 3]})
result = benchmark(lots_of_tables.execute, t)
assert len(result) == 3

0 comments on commit 53bf76c

Please sign in to comment.