MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / test_stress_c_extension

Function test_stress_c_extension

python/tests/test_c_extension.py:174–206  ·  view source on GitHub ↗

Stress test the C extension with large dataset.

()

Source from the content-addressed store, hash-verified

172
173
174def test_stress_c_extension():
175 """Stress test the C extension with large dataset."""
176 if not HAS_C_EXTENSION:
177 return
178
179 print("\nC Extension Stress Test")
180 print("=" * 40)
181
182 size = 100000
183 tree = bplustree_c.BPlusTree(capacity=128)
184
185 # Insert random data
186 keys = list(range(size))
187 random.shuffle(keys)
188
189 start = time.perf_counter()
190 for key in keys:
191 tree[key] = key * 2
192 insert_time = time.perf_counter() - start
193
194 print(f"Inserted {size:,} items in {insert_time:.3f}s")
195 print(f"Rate: {size/insert_time:,.0f} insertions/sec")
196
197 # Verify all items
198 start = time.perf_counter()
199 for key in range(size):
200 assert tree[key] == key * 2
201 lookup_time = time.perf_counter() - start
202
203 print(f"Verified {size:,} lookups in {lookup_time:.3f}s")
204 print(f"Rate: {size/lookup_time:,.0f} lookups/sec")
205
206 print("✓ Stress test passed")
207
208
209if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected