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

Class TestLargeDatasets

python/tests/test_stress_large_datasets.py:17–266  ·  view source on GitHub ↗

Stress tests with large datasets.

Source from the content-addressed store, hash-verified

15
16
17class TestLargeDatasets:
18 """Stress tests with large datasets."""
19
20 @pytest.mark.slow
21 def test_one_million_sequential_insertions(self):
22 """Test handling of 1M sequential insertions."""
23 tree = BPlusTreeMap()
24 size = 1_000_000
25
26 start_time = time.time()
27
28 # Insert 1M items
29 for i in range(size):
30 tree[i] = f"v{i}"
31
32 # Periodic progress check
33 if i % 100_000 == 0 and i > 0:
34 elapsed = time.time() - start_time
35 print(f"\nInserted {i:,} items in {elapsed:.2f}s")
36
37 total_time = time.time() - start_time
38 print(f"\nTotal insertion time for 1M items: {total_time:.2f}s")
39
40 # Verify all items are present
41 assert len(tree) == size
42
43 # Spot check some values
44 for i in range(0, size, 100_000):
45 assert tree[i] == f"v{i}"
46
47 @pytest.mark.slow
48 def test_one_million_random_insertions(self):
49 """Test handling of 1M random insertions."""
50 tree = BPlusTreeMap()
51 size = 1_000_000
52
53 # Generate random keys
54 keys = list(range(size))
55 random.shuffle(keys)
56
57 start_time = time.time()
58
59 # Insert in random order
60 for i, key in enumerate(keys):
61 tree[key] = f"value_{key}"
62
63 # Periodic progress check
64 if i % 100_000 == 0 and i > 0:
65 elapsed = time.time() - start_time
66 print(f"\nInserted {i:,} random items in {elapsed:.2f}s")
67
68 total_time = time.time() - start_time
69 print(f"\nTotal random insertion time for 1M items: {total_time:.2f}s")
70
71 # Verify all items are present and in order
72 assert len(tree) == size
73
74 # Check ordering

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected