MCPcopy Create free account
hub / github.com/p-ranav/tabulate / main

Function main

samples/benchmark.cpp:324–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322} // namespace
323
324int main() {
325 std::cout << "=== 1. Scaling: print() cost by table size (no formatting) ===\n";
326 Table scaling_results;
327 scaling_results.add_row(Row_t{"Rows", "Cols", "Cells", "Time", "Time/cell"});
328 benchmark_scaling(scaling_results);
329 scaling_results.column(3).format().font_align(FontAlign::right);
330 scaling_results.column(4).format().font_align(FontAlign::right);
331 std::cout << scaling_results << "\n\n";
332
333 std::cout << "=== 2. Feature cost: what does each feature add, on a 2000x5 table? ===\n";
334 Table feature_results;
335 feature_results.add_row(Row_t{"Scenario", "Time", "vs Baseline"});
336 benchmark_feature_costs(feature_results, 2000, 5);
337 feature_results.column(1).format().font_align(FontAlign::right);
338 feature_results.column(2).format().font_align(FontAlign::right);
339 std::cout << feature_results << "\n\n";
340
341 std::cout << "=== 3a. Word-wrap scaling: short single-line cells vs. all-wrapped cells"
342 << " (width=20), by table size ===\n";
343 Table wrap_scaling_results;
344 wrap_scaling_results.add_row(
345 Row_t{"Rows", "Cols", "Cells", "Baseline (no wrap)", "Wrapped", "Wrapped/Baseline"});
346 benchmark_word_wrap_scaling(wrap_scaling_results, 20);
347 wrap_scaling_results.column(3).format().font_align(FontAlign::right);
348 wrap_scaling_results.column(4).format().font_align(FontAlign::right);
349 wrap_scaling_results.column(5).format().font_align(FontAlign::right);
350 std::cout << wrap_scaling_results << "\n\n";
351
352 std::cout << "=== 3b. Word-wrap width sweep: 2000x5 table, narrower columns force more lines"
353 << " per cell ===\n";
354 Table wrap_width_results;
355 wrap_width_results.add_row(Row_t{"Column width", "Time", "vs width=80"});
356 benchmark_word_wrap_width_sweep(wrap_width_results, 2000, 5);
357 wrap_width_results.column(1).format().font_align(FontAlign::right);
358 wrap_width_results.column(2).format().font_align(FontAlign::right);
359 std::cout << wrap_width_results << "\n\n";
360
361 std::cout << "=== 4. Padding/repeated-string construction: std::string vs. std::format ===\n";
362 Table format_results;
363 format_results.add_row(Row_t{"Method", "Time"});
364 benchmark_padding_construction(format_results);
365 std::cout << format_results << std::endl;
366}
367

Callers

nothing calls this directly

Calls 8

benchmark_scalingFunction · 0.85
benchmark_feature_costsFunction · 0.85
add_rowMethod · 0.45
formatMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected