mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
GetTime() call can be now inlined.
No dependencies on either windows.h, or static instance of Profiler.
This commit is contained in:
parent
11a790a18f
commit
e5ad7d9ac4
@ -4,10 +4,6 @@
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __CYGWIN__
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
#include <atomic>
|
||||
#include <assert.h>
|
||||
#include <chrono>
|
||||
@ -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::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t Profiler::ZoneBegin( QueueZoneBegin&& data )
|
||||
{
|
||||
auto id = GetNewId();
|
||||
|
@ -2,12 +2,17 @@
|
||||
#define __TRACYPROFILER_HPP__
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <stdint.h>
|
||||
#include <thread>
|
||||
|
||||
#include "../common/tracy_lz4.hpp"
|
||||
#include "../common/TracyQueue.hpp"
|
||||
|
||||
#if defined _MSC_VER || defined __CYGWIN__
|
||||
# include <intrin.h>
|
||||
#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::nanoseconds>( 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 );
|
||||
|
Loading…
Reference in New Issue
Block a user