Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-07-26 21:33:49 +0200
committerMartin Hořeňovský2020-07-26 21:33:49 +0200
commit5f6990d74695bf5452d9d5870cf5760628497114 (patch)
tree85870348b6b09c570328206aa64ca18a6a85d815 /src/catch2
parent5ca68829e10cc28471d2340439b53a41e8ff4e63 (diff)
downloadcatch3-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')
-rw-r--r--src/catch2/internal/catch_section.cpp6
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() {