added new timing related command line options

2 new timing related command line options have been added:
- performance-timings [-p]: print out performance timings per test case
and group
- performance-timings-threshold [-q <secs>]: print out only the timings
exceeding this given threshold value
This commit is contained in:
Konstantin Baumann
2013-07-23 17:11:43 +02:00
parent 4e7b104f36
commit cdbcd6aa5e
5 changed files with 36 additions and 3 deletions

View File

@@ -74,6 +74,12 @@ namespace Catch {
Colour colour( Colour::ResultError );
stream << "\nNo assertions in test case, '" << _testCaseStats.testInfo.name << "'\n" << std::endl;
}
if( m_config->showTimings() && (_testCaseStats.timeSecs >= m_config->timingsThreshold()) ) {
Colour colour( Colour::SecondaryText );
stream << "Time spent in test case '" << _testCaseStats.testInfo.name << "': [timing: " << _testCaseStats.timeSecs << " secs]." << std::endl;
}
StreamingReporterBase::testCaseEnded( _testCaseStats );
m_headerPrinted = false;
}
@@ -84,13 +90,21 @@ namespace Catch {
printTotals( _testGroupStats.totals );
stream << "\n" << std::endl;
}
if( m_config->showTimings() && (_testGroupStats.timeSecs >= m_config->timingsThreshold()) ) {
Colour colour( Colour::SecondaryText );
stream << "Time spent in test group '" << _testGroupStats.groupInfo.name << "': [timing: " << _testGroupStats.timeSecs << " secs]." << std::endl;
}
StreamingReporterBase::testGroupEnded( _testGroupStats );
}
virtual void testRunEnded( TestRunStats const& _testRunStats ) {
if( m_atLeastOneTestCasePrinted )
printTotalsDivider();
printTotals( _testRunStats.totals );
stream << " [timing: " << _testRunStats.timeSecs << " secs.]";
if( m_config->showTimings() ) {
stream << " [timing: " << _testRunStats.timeSecs << " secs.]";
}
stream << "\n" << std::endl;
StreamingReporterBase::testRunEnded( _testRunStats );
}

View File

@@ -44,7 +44,7 @@ namespace Catch {
private:
static void OutputTestSuites( XmlWriter& xml, AccumTestRunStats const& stats ) {
xml.startElement( "testsuites" );
xml.writeAttribute( "name", stats.testRun.runInfo.name );
xml.writeAttribute( "time", stats.testRun.timeSecs );
std::vector<AccumTestGroupStats>::const_iterator it = stats.testGroups.begin();