Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-08-13 23:08:12 +0200
committerMartin Hořeňovský2023-08-13 23:09:02 +0200
commitad564634770d04eac3ce1819dce49f6df3d2639b (patch)
treedc34bb2359b0f08aa9ece1e54b119218a6bd860d /src/catch2
parent9538d160051c09150645c0ed9b135a67f79200e0 (diff)
downloadcatch3-ad564634770d04eac3ce1819dce49f6df3d2639b.tar.gz
Flush stream after benchmarkStarting in ConsoleReporter
This means that the user will see the estimation of full benchmark running time when it is available, unlike now when it often only ends up flushed after the benchmark is fully finished. This means that the user will almost immediately see the start of table like this ``` benchmark name samples iterations estimated mean low mean high mean std dev low std dev high std dev ------------------------------------------------------------------------------- Fill vector generated 100 54 3.0834 ms ``` This presents significant improvement in user experience especially for long running benchmarks.
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/reporters/catch_reporter_console.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp
index a46b22cf..04d6f128 100644
--- a/src/catch2/reporters/catch_reporter_console.cpp
+++ b/src/catch2/reporters/catch_reporter_console.cpp
@@ -218,6 +218,7 @@ struct ColumnInfo {
};
struct ColumnBreak {};
struct RowBreak {};
+struct OutputFlush {};
class Duration {
enum class Unit {
@@ -334,12 +335,12 @@ public:
}
template<typename T>
- friend TablePrinter& operator << (TablePrinter& tp, T const& value) {
+ friend TablePrinter& operator<< (TablePrinter& tp, T const& value) {
tp.m_oss << value;
return tp;
}
- friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) {
+ friend TablePrinter& operator<< (TablePrinter& tp, ColumnBreak) {
auto colStr = tp.m_oss.str();
const auto strSize = colStr.size();
tp.m_oss.str("");
@@ -361,13 +362,18 @@ public:
return tp;
}
- friend TablePrinter& operator << (TablePrinter& tp, RowBreak) {
+ friend TablePrinter& operator<< (TablePrinter& tp, RowBreak) {
if (tp.m_currentColumn > 0) {
tp.m_os << '\n';
tp.m_currentColumn = -1;
}
return tp;
}
+
+ friend TablePrinter& operator<<(TablePrinter& tp, OutputFlush) {
+ tp.m_os << std::flush;
+ return tp;
+ }
};
ConsoleReporter::ConsoleReporter(ReporterConfig&& config):
@@ -473,8 +479,11 @@ void ConsoleReporter::benchmarkPreparing( StringRef name ) {
void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) {
(*m_tablePrinter) << info.samples << ColumnBreak()
<< info.iterations << ColumnBreak();
- if (!m_config->benchmarkNoAnalysis())
- (*m_tablePrinter) << Duration(info.estimatedDuration) << ColumnBreak();
+ if ( !m_config->benchmarkNoAnalysis() ) {
+ ( *m_tablePrinter )
+ << Duration( info.estimatedDuration ) << ColumnBreak();
+ }
+ ( *m_tablePrinter ) << OutputFlush{};
}
void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) {
if (m_config->benchmarkNoAnalysis())