Skip to content

Commit

Permalink
switch text outputs to markdown, wip, ref #14
Browse files Browse the repository at this point in the history
  • Loading branch information
iboB committed Mar 6, 2024
1 parent a1c1610 commit e60294b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
26 changes: 9 additions & 17 deletions include/picobench/picobench.hpp
Expand Up @@ -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)
Expand Down Expand Up @@ -535,7 +535,7 @@ class report
out << setw(11) << fixed << setprecision(1) << ops_per_sec << "\n";
}
}
line(out);
out.put('\n');
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -611,7 +609,7 @@ class report
out << setw(12) << fixed << setprecision(1) << ops_per_sec << "\n";
}

line(out);
out.put('\n');
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -771,7 +763,7 @@ enum class report_output_format
{
text,
concise_text,
csv
csv,
};

#if !defined(PICOBENCH_DEFAULT_ITERATIONS)
Expand Down
32 changes: 16 additions & 16 deletions test/basic.cpp
Expand Up @@ -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"
Expand All @@ -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);
Expand Down

0 comments on commit e60294b

Please sign in to comment.