File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 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" )
You can’t perform that action at this time.
0 commit comments