Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

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.
Commit
5f6990d74695bf5452d9d5870cf5760628497114
Author
Martin Hořeňovský ·
Parents
5ca68829e10c

Files · Download .tar.gz

Changes

 src/catch2/internal/catch_section.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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() {