From 354be4181172c9fd1d863131d9337b3e1628383e Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Wed, 11 Jul 2018 15:44:25 +0200 Subject: [PATCH] benchmarks: clarify output Make it clear in benchmark output which mode it ran in: - "main thread" only - "1 worker" thread - "N workers" --- benchmark/include/bench_framework.hpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/benchmark/include/bench_framework.hpp b/benchmark/include/bench_framework.hpp index 32639ed85..df2a9e57b 100644 --- a/benchmark/include/bench_framework.hpp +++ b/benchmark/include/bench_framework.hpp @@ -12,6 +12,7 @@ #include #include // log10, round #include // snprintf +#include #include #include #include @@ -239,14 +240,19 @@ int run(T const& test_runner, std::string const& name) big_number_fmt itersf(4, total_iters); big_number_fmt ips(5, total_iters / seconds(elapsed_nonzero).count()); + std::clog << std::left << std::setw(43) << name; + std::clog << std::resetiosflags(std::ios::adjustfield); + if (num_threads > 0) { + std::clog << ' ' << std::setw(3) << num_threads + << " worker" << (num_threads > 1 ? "s" : " "); + } + else { + std::clog << " main thread"; + } std::snprintf(msg, sizeof(msg), - "%-43s %3zu thread(s) %*.0f%s iters %6.0f milliseconds %*.0f%s i/s\n", - name.c_str(), - num_threads, - itersf.w, itersf.v, itersf.u, - dur_total, - ips.w, ips.v, ips.u - ); + " %*.0f%s iters %6.0f milliseconds %*.0f%s i/t/s\n", + itersf.w, itersf.v, itersf.u, dur_total, + ips.w, ips.v, ips.u); std::clog << msg; return 0; }