diff --git a/source/MRMesh/MRTimer.cpp b/source/MRMesh/MRTimer.cpp index e52370ac2959..9214c3749190 100644 --- a/source/MRMesh/MRTimer.cpp +++ b/source/MRMesh/MRTimer.cpp @@ -124,6 +124,7 @@ void Timer::start( const std::string& name ) { if ( std::this_thread::get_id() != mainThreadId ) return; + started_ = true; start_ = high_resolution_clock::now(); auto parent = currentRecord; currentRecord = &parent->children[name]; @@ -132,6 +133,8 @@ void Timer::start( const std::string& name ) void Timer::finish() { + if ( !started_ ) + return; auto currentParent = currentRecord->parent; if ( !currentParent ) return; diff --git a/source/MRMesh/MRTimer.h b/source/MRMesh/MRTimer.h index a53633a784e6..7d829b70b3b0 100644 --- a/source/MRMesh/MRTimer.h +++ b/source/MRMesh/MRTimer.h @@ -31,6 +31,7 @@ class Timer private: std::chrono::time_point start_; + bool started_{ false }; }; /// enables or disables printing of timing tree when application terminates