Measure peak memory usage during unpickling.
(self)
| 258 | } |
| 259 | |
| 260 | def benchmark_memory(self) -> int: |
| 261 | """Measure peak memory usage during unpickling.""" |
| 262 | tracemalloc.start() |
| 263 | |
| 264 | # Warmup |
| 265 | pickle.loads(self.pickle_data) |
| 266 | |
| 267 | # Actual measurement |
| 268 | gc.collect() |
| 269 | tracemalloc.reset_peak() |
| 270 | result = pickle.loads(self.pickle_data) |
| 271 | current, peak = tracemalloc.get_traced_memory() |
| 272 | |
| 273 | tracemalloc.stop() |
| 274 | |
| 275 | # Verify correctness |
| 276 | if result != self.obj: |
| 277 | raise ValueError("Unpickled object doesn't match original!") |
| 278 | |
| 279 | return peak |
| 280 | |
| 281 | def run_all(self) -> Dict[str, Any]: |
| 282 | """Run all benchmarks and return comprehensive results.""" |