MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / main

Function main

benchmark/compare_formats.py:123–259  ·  view source on GitHub ↗

Run all benchmarks.

()

Source from the content-addressed store, hash-verified

121
122
123def main():
124 """Run all benchmarks."""
125 from sample_datasets import DATASETS
126
127 print_header("🚀 TOON vs JSON: THE ULTIMATE SHOWDOWN 🚀", 80)
128 print("\n" + " " * 10 + "Testing across 50 diverse, real-world datasets")
129 print(" " * 10 + "Measuring size, tokens, and performance\n")
130
131 results = []
132
133 # Show detailed output for first 10 datasets
134 print("\n" + "▼" * 80)
135 print("DETAILED RESULTS (First 10 Datasets)")
136 print("▼" * 80)
137
138 for i, (dataset_name, dataset) in enumerate(DATASETS.items()):
139 if i < 10:
140 result = benchmark_dataset(dataset_name, dataset, verbose=True)
141 else:
142 # Silent benchmarking for remaining datasets
143 if i == 10:
144 print("\n" + "⚡" * 80)
145 print(" Processing remaining 40 datasets...")
146 print("⚡" * 80)
147 result = benchmark_dataset(dataset_name, dataset, verbose=False)
148 print(f" ✓ {dataset_name:<50} ({result['size_savings']:.1f}% size, {result['token_savings']:.1f}% tokens)")
149 results.append(result)
150
151 # Calculate aggregate statistics
152 total_json_size = sum(r['json_size'] for r in results)
153 total_toon_size = sum(r['toon_size'] for r in results)
154 total_json_tokens = sum(r['json_tokens'] for r in results)
155 total_toon_tokens = sum(r['toon_tokens'] for r in results)
156
157 avg_size_savings = calculate_savings(total_json_size, total_toon_size)
158 avg_token_savings = calculate_savings(total_json_tokens, total_toon_tokens)
159
160 total_size_saved = total_json_size - total_toon_size
161 total_tokens_saved = total_json_tokens - total_toon_tokens
162
163 # Best performers
164 best_size = max(results, key=lambda x: x['size_savings'])
165 best_tokens = max(results, key=lambda x: x['token_savings'])
166
167 # Print epic summary
168 print_header("📈 AGGREGATE RESULTS ACROSS ALL 50 DATASETS 📈", 80)
169
170 print(f"\n{'┌' + '─'*78 + '┐'}")
171 print(f"│{'TOTAL DATA SIZE':^78}│")
172 print(f"│{' '*78}│")
173 print(f"│ JSON: {format_size(total_json_size):>15} ({total_json_size:,} bytes){' '*(32-len(str(total_json_size)))}│")
174 print(f"│ TOON: {format_size(total_toon_size):>15} ({total_toon_size:,} bytes){' '*(32-len(str(total_toon_size)))}│")
175 print(f"│ SAVED: {format_size(total_size_saved):>15} (⬇ {avg_size_savings:.1f}%){' '*(41-len(f'{avg_size_savings:.1f}'))}│")
176 print(f"{'└' + '─'*78 + '┘'}")
177
178 print(f"\n{'┌' + '─'*78 + '┐'}")
179 print(f"│{'TOTAL TOKEN COUNT (GPT-4)':^78}│")
180 print(f"│{' '*78}│")

Callers 1

compare_formats.pyFile · 0.70

Calls 5

print_headerFunction · 0.85
benchmark_datasetFunction · 0.85
calculate_savingsFunction · 0.85
print_savings_barFunction · 0.85
format_sizeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…