From e5ad7d9ac43b1ad8dd69f0d8f0ee2faf815ea7dc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 26 Sep 2017 00:42:09 +0200 Subject: [PATCH] GetTime() call can be now inlined. No dependencies on either windows.h, or static instance of Profiler. --- client/TracyProfiler.cpp | 14 -------------- client/TracyProfiler.hpp | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 37498112..bd62810d 100755 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -4,10 +4,6 @@ # include #endif -#if defined _MSC_VER || defined __CYGWIN__ -# include -#endif - #include #include #include @@ -82,16 +78,6 @@ uint64_t Profiler::GetNewId() return s_instance->m_id.fetch_add( 1, std::memory_order_relaxed ); } -int64_t Profiler::GetTime() -{ -#if defined _MSC_VER || defined __CYGWIN__ - unsigned int ui; - return int64_t( __rdtscp( &ui ) ); -#else - return std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); -#endif -} - uint64_t Profiler::ZoneBegin( QueueZoneBegin&& data ) { auto id = GetNewId(); diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index e7a1adc0..6ad8d75d 100755 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -2,12 +2,17 @@ #define __TRACYPROFILER_HPP__ #include +#include #include #include #include "../common/tracy_lz4.hpp" #include "../common/TracyQueue.hpp" +#if defined _MSC_VER || defined __CYGWIN__ +# include +#endif + namespace tracy { @@ -20,7 +25,15 @@ public: ~Profiler(); static uint64_t GetNewId(); - static int64_t GetTime(); + static int64_t GetTime() + { +#if defined _MSC_VER || defined __CYGWIN__ + unsigned int ui; + return int64_t( __rdtscp( &ui ) ); +#else + return std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); +#endif + } static uint64_t ZoneBegin( QueueZoneBegin&& data ); static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );