diff options
| author | Martin Hořeňovský | 2020-07-26 21:33:49 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-07-26 21:33:49 +0200 |
| commit | 5f6990d74695bf5452d9d5870cf5760628497114 (patch) | |
| tree | 85870348b6b09c570328206aa64ca18a6a85d815 /src/catch2/internal/catch_section.cpp | |
| parent | 5ca68829e10cc28471d2340439b53a41e8ff4e63 (diff) | |
| download | catch3-5f6990d74695bf5452d9d5870cf5760628497114.tar.gz | |
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.
Diffstat (limited to 'src/catch2/internal/catch_section.cpp')
| -rw-r--r-- | src/catch2/internal/catch_section.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/catch2/internal/catch_section.cpp b/src/catch2/internal/catch_section.cpp index 3652daf0..52361584 100644 --- a/src/catch2/internal/catch_section.cpp +++ b/src/catch2/internal/catch_section.cpp @@ -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() { |