Skip to content

Commit fe56b04

Browse files
committed
Add from_pyarrow benchmarks
1 parent 967f868 commit fe56b04

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test_tables.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,3 +2030,24 @@ def test_construct_from_chunked_array_wrong_type(self):
20302030

20312031
with pytest.raises(ValueError):
20322032
Pair.from_kwargs(x=x, y=y)
2033+
2034+
2035+
@pytest.mark.parametrize("N", [100_000, 1_000_000, 10_000_000])
2036+
@pytest.mark.benchmark(group="from-pyarrow")
2037+
def test_bench_from_pyarrow_matching_schema(benchmark, N):
2038+
N = 1_000_000
2039+
x = pa.array(np.random.randint(low=-1000, high=1000, size=N), type=pa.int64())
2040+
y = pa.array(np.random.randint(low=-1000, high=1000, size=N), type=pa.int64())
2041+
table = pa.table({"x": x, "y": y}, schema=Pair.schema)
2042+
2043+
benchmark(Pair.from_pyarrow, table)
2044+
2045+
2046+
@pytest.mark.parametrize("N", [100_000, 1_000_000, 10_000_000])
2047+
@pytest.mark.benchmark(group="from-pyarrow")
2048+
def test_bench_from_pyarrow_needs_cast(benchmark, N):
2049+
x = pa.array(np.random.randint(low=-1000, high=1000, size=N), type=pa.int32())
2050+
y = pa.array(np.random.randint(low=-1000, high=1000, size=N), type=pa.int64())
2051+
table = pa.table({"x": x, "y": y})
2052+
2053+
benchmark(Pair.from_pyarrow, table)

0 commit comments

Comments
 (0)