@@ -61,12 +61,15 @@ def _ensure_bench_tsfile(file_path: str, row_count: int) -> None:
6161 remove (file_path )
6262 # Build data with pandas/numpy (vectorized, much faster than row-by-row Tablet)
6363 import numpy as np
64- df = pd .DataFrame ({
65- "time" : np .arange (row_count , dtype = np .int64 ),
66- "device" : pd .Series ([f"device" for i in range (row_count )]),
67- "value1" : np .arange (0 , row_count * 10 , 10 , dtype = np .int64 ),
68- "value2" : np .arange (row_count , dtype = np .float64 ) * 1.5 ,
69- })
64+
65+ df = pd .DataFrame (
66+ {
67+ "time" : np .arange (row_count , dtype = np .int64 ),
68+ "device" : pd .Series ([f"device" for i in range (row_count )]),
69+ "value1" : np .arange (0 , row_count * 10 , 10 , dtype = np .int64 ),
70+ "value2" : np .arange (row_count , dtype = np .float64 ) * 1.5 ,
71+ }
72+ )
7073
7174 table = TableSchema (
7275 TABLE_NAME ,
@@ -135,7 +138,9 @@ def _run_timed(name: str, func, *args, rounds: int = DEFAULT_TIMED_ROUNDS):
135138 avg = sum (times ) / len (times )
136139 total_rows = n
137140 rows_per_sec = total_rows / avg if avg > 0 else 0
138- print (f" { name } : { avg :.3f} s avg ({ min (times ):.3f} s min) rows={ total_rows } { rows_per_sec :.0f} rows/s" )
141+ print (
142+ f" { name } : { avg :.3f} s avg ({ min (times ):.3f} s min) rows={ total_rows } { rows_per_sec :.0f} rows/s"
143+ )
139144 return avg , total_rows
140145
141146
@@ -148,7 +153,9 @@ def run_benchmark(
148153 _ensure_bench_tsfile (file_path , row_count )
149154 end_time = row_count + 1
150155
151- print (f"Benchmark: { row_count } rows, batch_size={ batch_size } , timed_rounds={ timed_rounds } " )
156+ print (
157+ f"Benchmark: { row_count } rows, batch_size={ batch_size } , timed_rounds={ timed_rounds } "
158+ )
152159
153160 df_avg , df_rows = _run_timed (
154161 "query_table + read_data_frame" ,
@@ -170,7 +177,9 @@ def run_benchmark(
170177 print ()
171178 if df_avg > 0 :
172179 speedup = arrow_avg / df_avg
173- print (f" Arrow vs DataFrame time ratio: { speedup :.2f} x ({ 'Arrow faster' if speedup < 1 else 'DataFrame faster' } )" )
180+ print (
181+ f" Arrow vs DataFrame time ratio: { speedup :.2f} x ({ 'Arrow faster' if speedup < 1 else 'DataFrame faster' } )"
182+ )
174183 assert df_rows == row_count , f"DataFrame path row count { df_rows } != { row_count } "
175184 assert arrow_rows == row_count , f"Arrow path row count { arrow_rows } != { row_count } "
176185
0 commit comments