MCPcopy Create free account
hub / github.com/erans/pgsqlite / print_results

Method print_results

benchmarks/benchmark_array_binary.py:273–327  ·  view source on GitHub ↗

Print benchmark results in a formatted table

(self)

Source from the content-addressed store, hash-verified

271 self.print_results()
272
273 def print_results(self):
274 """Print benchmark results in a formatted table"""
275 print(f"\n{Fore.GREEN}📊 Array Binary Protocol Performance Results{Style.RESET_ALL}")
276 print("=" * 80)
277
278 # Group results by array size
279 size_groups = {}
280 for result in self.results:
281 if result.array_size not in size_groups:
282 size_groups[result.array_size] = []
283 size_groups[result.array_size].append(result)
284
285 for array_size in sorted(size_groups.keys()):
286 print(f"\n{Fore.YELLOW}Array Size: {array_size} elements{Style.RESET_ALL}")
287
288 table_data = []
289 for result in size_groups[array_size]:
290 overhead_color = ""
291 if result.overhead_factor < 100:
292 overhead_color = Fore.GREEN
293 elif result.overhead_factor < 500:
294 overhead_color = Fore.YELLOW
295 else:
296 overhead_color = Fore.RED
297
298 table_data.append([
299 result.operation,
300 f"{result.sqlite_time:.3f}",
301 f"{result.pgsqlite_time:.3f}",
302 f"{overhead_color}{result.overhead_factor:.1f}x{Style.RESET_ALL}"
303 ])
304
305 headers = ["Operation", "SQLite (ms)", "pgsqlite (ms)", "Overhead"]
306 print(tabulate(table_data, headers=headers, tablefmt="grid"))
307
308 # Summary
309 print(f"\n{Fore.CYAN}📈 Summary{Style.RESET_ALL}")
310 avg_overhead_by_op = {}
311 for result in self.results:
312 if result.operation not in avg_overhead_by_op:
313 avg_overhead_by_op[result.operation] = []
314 avg_overhead_by_op[result.operation].append(result.overhead_factor)
315
316 summary_data = []
317 for operation, overheads in avg_overhead_by_op.items():
318 avg_overhead = statistics.mean(overheads)
319 color = Fore.GREEN if avg_overhead < 100 else Fore.YELLOW if avg_overhead < 500 else Fore.RED
320 summary_data.append([
321 operation,
322 f"{color}{avg_overhead:.1f}x{Style.RESET_ALL}"
323 ])
324
325 print(tabulate(summary_data, headers=["Operation", "Avg Overhead"], tablefmt="grid"))
326
327 print(f"\n{Fore.GREEN}✅ Array binary protocol benchmarking complete!{Style.RESET_ALL}")
328
329def main():
330 import argparse

Callers 1

run_benchmarksMethod · 0.95

Calls 1

keysMethod · 0.80

Tested by

no test coverage detected