mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
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.
This commit is contained in:
parent
9538d16005
commit
ad56463477
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user