MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_performance_comparison

Function test_performance_comparison

ci/tests/test_fingerprint_integration.py:131–178  ·  view source on GitHub ↗

Compare performance across cache types.

()

Source from the content-addressed store, hash-verified

129
130
131def test_performance_comparison() -> None:
132 """Compare performance across cache types."""
133 with tempfile.TemporaryDirectory() as temp_dir:
134 temp_path = Path(temp_dir)
135 test_dir = temp_path / "test_files"
136 cache_dir = temp_path / ".cache"
137 cache_dir.mkdir(exist_ok=True)
138
139 create_test_files(test_dir, 100)
140 include = ["**/*.txt"]
141 root = str(test_dir)
142
143 # TwoLayerFingerprintCache performance
144 two_layer = TwoLayerFingerprintCache(cache_dir, "perf_two_layer")
145 start = time.time()
146 two_layer.check_needs_update(include=include, root=root)
147 two_layer_time = time.time() - start
148 two_layer.mark_success()
149
150 # Cache hit performance
151 start = time.time()
152 two_layer.check_needs_update(include=include, root=root)
153 two_layer_hit_time = time.time() - start
154
155 assert two_layer_time < 15.0, (
156 f"TwoLayerFingerprintCache first check too slow: {two_layer_time:.3f}s"
157 )
158 assert two_layer_hit_time < 5.0, (
159 f"TwoLayerFingerprintCache cache hit too slow: {two_layer_hit_time:.3f}s"
160 )
161
162 # HashFingerprintCache performance
163 hash_cache = HashFingerprintCache(cache_dir, "perf_hash")
164 start = time.time()
165 hash_cache.check_needs_update(include=include, root=root)
166 hash_time = time.time() - start
167 hash_cache.mark_success()
168
169 start = time.time()
170 hash_cache.check_needs_update(include=include, root=root)
171 hash_hit_time = time.time() - start
172
173 assert hash_time < 5.0, (
174 f"HashFingerprintCache first check too slow: {hash_time:.3f}s"
175 )
176 assert hash_hit_time < 5.0, (
177 f"HashFingerprintCache cache hit too slow: {hash_hit_time:.3f}s"
178 )
179
180
181def test_accuracy_all_caches() -> None:

Callers

nothing calls this directly

Calls 8

check_needs_updateMethod · 0.95
mark_successMethod · 0.95
check_needs_updateMethod · 0.95
mark_successMethod · 0.95
timeMethod · 0.80
create_test_filesFunction · 0.70

Tested by

no test coverage detected