@@ -59,11 +59,11 @@ def clean() -> None:
5959# Section 1: bulk creation — extend()
6060# ---------------------------------------------------------------------------
6161
62- sep ("1. extend() — bulk insert: in-memory vs file -backed" )
62+ sep ("1. extend() — bulk insert: in-memory vs TreeStore -backed" )
6363
6464SIZES = [1_000 , 10_000 , 100_000 , 1_000_000 ]
6565
66- print (f"{ 'rows' :>12} { 'in-memory (s)' :>16} { 'file -backed (s)' :>16} { 'overhead' :>10} " )
66+ print (f"{ 'rows' :>12} { 'in-memory (s)' :>16} { 'store -backed (s)' :>16} { 'overhead' :>10} " )
6767print (f"{ '----' :>12} { '-------------' :>16} { '---------------' :>16} { '--------' :>10} " )
6868
6969for N in SIZES :
@@ -77,6 +77,7 @@ def bench_file(N=N, data=data):
7777 clean ()
7878 t = blosc2 .CTable (Row , urlpath = TABLE_DIR + "/ext" , mode = "w" , expected_size = N )
7979 t .extend (data , validate = False )
80+ t .close ()
8081
8182 t_mem = tmin (bench_mem )
8283 t_file = tmin (bench_file )
@@ -89,16 +90,20 @@ def bench_file(N=N, data=data):
8990
9091sep ("2. open() — time to reopen a persistent table" )
9192
92- print (f"{ 'rows' :>12} { 'CTable.open() (s)' :>20} { 'CTable(..., mode=a) (s)' :>24} " )
93- print (f"{ '----' :>12} { '------------------' :>20} { '------------------------' :>24} " )
93+ print (f"{ 'rows' :>12} { 'blosc2.open() (s)' :>18 } { ' CTable.open() (s)' :>20} { 'CTable(..., mode=a) (s)' :>24} " )
94+ print (f"{ '----' :>12} { '----------------' :>18 } { '---------------- --' :>20} { '------------------------' :>24} " )
9495
9596for N in SIZES :
9697 data = [(i , float (i % 100 ), i % 2 == 0 ) for i in range (N )]
9798 clean ()
9899 path = TABLE_DIR + "/reopen"
99100 t = blosc2 .CTable (Row , urlpath = path , mode = "w" , expected_size = N )
100101 t .extend (data , validate = False )
101- del t
102+ t .close ()
103+
104+ def bench_blosc2_open (path = path ):
105+ t2 = blosc2 .open (path , mode = "r" )
106+ _ = len (t2 )
102107
103108 def bench_open (path = path ):
104109 t2 = blosc2 .CTable .open (path , mode = "r" )
@@ -108,15 +113,16 @@ def bench_ctor(path=path):
108113 t2 = blosc2 .CTable (Row , urlpath = path , mode = "a" )
109114 _ = len (t2 )
110115
116+ t_b2_open = tmin (bench_blosc2_open )
111117 t_open = tmin (bench_open )
112118 t_ctor = tmin (bench_ctor )
113- print (f"{ N :>12,} { t_open :>20.4f} { t_ctor :>24.4f} " )
119+ print (f"{ N :>12,} { t_b2_open :>18.4f } { t_open :>20.4f} { t_ctor :>24.4f} " )
114120
115121# ---------------------------------------------------------------------------
116122# Section 3: append() — single-row inserts after reopen
117123# ---------------------------------------------------------------------------
118124
119- sep ("3. append() — 1 000 single-row inserts: in-memory vs file -backed" )
125+ sep ("3. append() — 1 000 single-row inserts: in-memory vs TreeStore -backed" )
120126
121127APPEND_N = 1_000
122128PREALLOCATE = 10_000 # avoid resize noise
@@ -146,7 +152,8 @@ def bench_append_file():
146152 # Reset file table before each run
147153 if label == "file-backed" :
148154 clean ()
149- blosc2 .CTable (Row , urlpath = path , mode = "w" , expected_size = PREALLOCATE )
155+ t = blosc2 .CTable (Row , urlpath = path , mode = "w" , expected_size = PREALLOCATE )
156+ t .close ()
150157 elapsed = tmin (fn )
151158 us_per_row = elapsed / APPEND_N * 1e6
152159 print (f"{ label :>14} { elapsed :>12.4f} { us_per_row :>12.1f} " )
@@ -155,9 +162,9 @@ def bench_append_file():
155162# Section 4: column read — to_numpy() after reopen
156163# ---------------------------------------------------------------------------
157164
158- sep ("4. column read — to_numpy() on 'id': in-memory vs file -backed" )
165+ sep ("4. column read — to_numpy() on 'id': in-memory vs TreeStore -backed" )
159166
160- print (f"{ 'rows' :>12} { 'in-memory (s)' :>16} { 'file -backed (s)' :>16} { 'ratio' :>8} " )
167+ print (f"{ 'rows' :>12} { 'in-memory (s)' :>16} { 'store -backed (s)' :>16} { 'ratio' :>8} " )
161168print (f"{ '----' :>12} { '-------------' :>16} { '---------------' :>16} { '-----' :>8} " )
162169
163170for N in SIZES :
@@ -170,6 +177,7 @@ def bench_append_file():
170177 path = TABLE_DIR + "/read"
171178 t_file_table = blosc2 .CTable (Row , urlpath = path , mode = "w" , expected_size = N )
172179 t_file_table .extend (data , validate = False )
180+ t_file_table .close ()
173181 # Reopen read-only (simulates a real read workload)
174182 t_ro = blosc2 .CTable .open (path , mode = "r" )
175183
0 commit comments