Format results for display.
(results: Dict[str, Any])
| 185 | |
| 186 | |
| 187 | def format_results(results: Dict[str, Any]) -> str: |
| 188 | """Format results for display.""" |
| 189 | output = [] |
| 190 | output.append("\n" + "=" * 60) |
| 191 | output.append("B+ Tree Performance Benchmark Results") |
| 192 | output.append("=" * 60) |
| 193 | |
| 194 | for test_name, data in results.items(): |
| 195 | output.append(f"\n{test_name}:") |
| 196 | if "duration" in data: |
| 197 | output.append(f" Duration: {data['duration']:.4f} seconds") |
| 198 | if "ops_per_second" in data: |
| 199 | output.append(f" Operations/second: {data['ops_per_second']:,.0f}") |
| 200 | else: |
| 201 | for key, value in data.items(): |
| 202 | if isinstance(value, float): |
| 203 | output.append(f" {key}: {value:.4f}") |
| 204 | else: |
| 205 | output.append(f" {key}: {value}") |
| 206 | |
| 207 | output.append("\n" + "=" * 60) |
| 208 | return "\n".join(output) |
| 209 | |
| 210 | |
| 211 | def save_results(results: Dict[str, Any], filename: str = None): |