Skip to content

Commit 1b7b66a

Browse files
committed
Add run_repr.py
1 parent 14729fc commit 1b7b66a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

python/tests/run_repr.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pyarrow as pa
2+
from datafusion import (
3+
SessionContext,
4+
)
5+
import time
6+
7+
RUNS = 1000
8+
9+
10+
def run_dataframe_repr_long() -> None:
11+
ctx = SessionContext()
12+
# Create a DataFrame with more than 10 rows
13+
batch = pa.RecordBatch.from_arrays(
14+
[
15+
pa.array(list(range(15))),
16+
pa.array([x * 2 for x in range(15)]),
17+
pa.array([x * 3 for x in range(15)]),
18+
],
19+
names=["a", "b", "c"],
20+
)
21+
df = ctx.create_dataframe([[batch]])
22+
23+
output = repr(df)
24+
25+
26+
def average_runtime(func, runs=RUNS):
27+
total_time = 0
28+
for _ in range(runs):
29+
start_time = time.time()
30+
func()
31+
end_time = time.time()
32+
total_time += end_time - start_time
33+
return total_time / runs
34+
35+
36+
average_time = average_runtime(run_dataframe_repr_long)
37+
print(f"Average runtime over {RUNS} runs: {average_time:.6f} seconds")

0 commit comments

Comments
 (0)