From e60294b6bae19c0a1a97f290868b017a78c6bcaf Mon Sep 17 00:00:00 2001 From: Borislav Stanimirov Date: Wed, 6 Mar 2024 17:06:46 +0200 Subject: [PATCH] switch text outputs to markdown, wip, ref #14 --- include/picobench/picobench.hpp | 26 +++++++++----------------- test/basic.cpp | 32 ++++++++++++++++---------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/include/picobench/picobench.hpp b/include/picobench/picobench.hpp index f88a706..d268e11 100644 --- a/include/picobench/picobench.hpp +++ b/include/picobench/picobench.hpp @@ -462,13 +462,13 @@ class report { if (suite.name) { - out << suite.name << ":\n"; + out << "## " << suite.name << ":\n"; } - line(out); + out.put('\n'); out << " Name (* = baseline) | Dim | Total ms | ns/op |Baseline| Ops/second\n"; - line(out); + out.put('\n'); auto problem_space_view = get_problem_space_view(suite); for (auto& ps : problem_space_view) @@ -535,7 +535,7 @@ class report out << setw(11) << fixed << setprecision(1) << ops_per_sec << "\n"; } } - line(out); + out.put('\n'); } } @@ -546,15 +546,13 @@ class report { if (suite.name) { - out << suite.name << ":\n"; + out << "## " << suite.name << ":\n"; } - line(out); - + out.put('\n'); out << " Name (* = baseline) | ns/op | Baseline | Ops/second\n"; - - line(out); + out.put('\n'); const benchmark* baseline = nullptr; for (auto& bm : suite.benchmarks) @@ -611,7 +609,7 @@ class report out << setw(12) << fixed << setprecision(1) << ops_per_sec << "\n"; } - line(out); + out.put('\n'); } } @@ -697,12 +695,6 @@ class report } private: - - static void line(std::ostream& out) - { - for (int i = 0; i < 79; ++i) out.put('='); - out.put('\n'); - } }; class benchmark_impl : public benchmark @@ -771,7 +763,7 @@ enum class report_output_format { text, concise_text, - csv + csv, }; #if !defined(PICOBENCH_DEFAULT_ITERATIONS) diff --git a/test/basic.cpp b/test/basic.cpp index 7310acd..1665d82 100644 --- a/test/basic.cpp +++ b/test/basic.cpp @@ -487,29 +487,29 @@ TEST_CASE("[picobench] test") sout.str(string()); report.to_text_concise(sout); const char* concise = - "test a:\n" - "===============================================================================\n" + "## test a:\n" + "\n" " Name (* = baseline) | ns/op | Baseline | Ops/second\n" - "===============================================================================\n" + "\n" " a_a * | 10 | - | 100000000.0\n" " a_b | 11 | 1.100 | 90909090.9\n" " a_c | 20 | 2.000 | 50000000.0\n" - "===============================================================================\n" - "test b:\n" - "===============================================================================\n" + "\n" + "## test b:\n" + "\n" " Name (* = baseline) | ns/op | Baseline | Ops/second\n" - "===============================================================================\n" + "\n" " b_a | 75 | 0.750 | 13333333.3\n" " something else * | 100 | - | 10000000.0\n" - "===============================================================================\n"; + "\n"; CHECK(sout.str() == concise); const char* txt = - "test a:\n" - "===============================================================================\n" + "## test a:\n" + "\n" " Name (* = baseline) | Dim | Total ms | ns/op |Baseline| Ops/second\n" - "===============================================================================\n" + "\n" " a_a * | 8 | 0.000 | 10 | - |100000000.0\n" " a_b | 8 | 0.000 | 11 | 1.100 | 90909090.9\n" " a_c | 8 | 0.000 | 20 | 2.000 | 50000000.0\n" @@ -525,18 +525,18 @@ TEST_CASE("[picobench] test") " a_a * | 8192 | 0.082 | 10 | - |100000000.0\n" " a_b | 8192 | 0.090 | 11 | 1.100 | 90909090.9\n" " a_c | 8192 | 0.164 | 20 | 2.000 | 50000000.0\n" - "===============================================================================\n" - "test b:\n" - "===============================================================================\n" + "\n" + "## test b:\n" + "\n" " Name (* = baseline) | Dim | Total ms | ns/op |Baseline| Ops/second\n" - "===============================================================================\n" + "\n" " something else * | 10 | 0.001 | 100 | - | 10000000.0\n" " b_a | 20 | 0.002 | 75 | 0.750 | 13333333.3\n" " something else * | 20 | 0.002 | 100 | - | 10000000.0\n" " b_a | 30 | 0.002 | 75 | 0.750 | 13333333.3\n" " something else * | 30 | 0.003 | 100 | - | 10000000.0\n" " b_a | 50 | 0.004 | 75 | ??? | 13333333.3\n" - "===============================================================================\n"; + "\n"; sout.str(string()); report.to_text(sout);