Only start Section's timer if the duration will be used

This is a small potential runtime optimization on systems with
virtual syscalls, and a significant runtime optimization on systems
without.
This commit is contained in:
Martin Hořeňovský 2020-07-26 21:33:49 +02:00
parent 5ca68829e1
commit 5f6990d746
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
1 changed files with 5 additions and 1 deletions

View File

@ -16,7 +16,11 @@ namespace Catch {
: m_info( info ),
m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
{
m_timer.start();
// Non-"included" sections will not use the timing information
// anyway, so don't bother with the potential syscall.
if (m_sectionIncluded) {
m_timer.start();
}
}
Section::~Section() {