mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +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>
|
# include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined _MSC_VER || defined __CYGWIN__
|
|
||||||
# include <intrin.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -82,16 +78,6 @@ uint64_t Profiler::GetNewId()
|
|||||||
return s_instance->m_id.fetch_add( 1, std::memory_order_relaxed );
|
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 )
|
uint64_t Profiler::ZoneBegin( QueueZoneBegin&& data )
|
||||||
{
|
{
|
||||||
auto id = GetNewId();
|
auto id = GetNewId();
|
||||||
|
@ -2,12 +2,17 @@
|
|||||||
#define __TRACYPROFILER_HPP__
|
#define __TRACYPROFILER_HPP__
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "../common/tracy_lz4.hpp"
|
#include "../common/tracy_lz4.hpp"
|
||||||
#include "../common/TracyQueue.hpp"
|
#include "../common/TracyQueue.hpp"
|
||||||
|
|
||||||
|
#if defined _MSC_VER || defined __CYGWIN__
|
||||||
|
# include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -20,7 +25,15 @@ public:
|
|||||||
~Profiler();
|
~Profiler();
|
||||||
|
|
||||||
static uint64_t GetNewId();
|
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 uint64_t ZoneBegin( QueueZoneBegin&& data );
|
||||||
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );
|
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );
|
||||||
|
Loading…
Reference in New Issue
Block a user