mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 04:43:53 +00:00
Hide GetTime() in Profiler.
This commit is contained in:
parent
c0b1846a35
commit
bd9ffc16b5
@ -5,6 +5,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <chrono>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -71,6 +72,11 @@ 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()
|
||||||
|
{
|
||||||
|
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Profiler::ZoneBegin( QueueZoneBegin&& data )
|
uint64_t Profiler::ZoneBegin( QueueZoneBegin&& data )
|
||||||
{
|
{
|
||||||
auto id = GetNewId();
|
auto id = GetNewId();
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define __TRACYPROFILER_HPP__
|
#define __TRACYPROFILER_HPP__
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
@ -14,11 +13,6 @@ namespace tracy
|
|||||||
|
|
||||||
class Socket;
|
class Socket;
|
||||||
|
|
||||||
static inline int64_t GetTime()
|
|
||||||
{
|
|
||||||
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
|
||||||
}
|
|
||||||
|
|
||||||
class Profiler
|
class Profiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -26,6 +20,7 @@ public:
|
|||||||
~Profiler();
|
~Profiler();
|
||||||
|
|
||||||
static uint64_t GetNewId();
|
static uint64_t GetNewId();
|
||||||
|
static int64_t GetTime();
|
||||||
|
|
||||||
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 );
|
||||||
|
@ -13,13 +13,13 @@ class ScopedZone
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopedZone( const char* file, const char* function, uint32_t line )
|
ScopedZone( const char* file, const char* function, uint32_t line )
|
||||||
: m_id( Profiler::ZoneBegin( QueueZoneBegin { GetTime(), (uint64_t)file, (uint64_t)function, line, GetThreadHandle() } ) )
|
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)file, (uint64_t)function, line, GetThreadHandle() } ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScopedZone()
|
~ScopedZone()
|
||||||
{
|
{
|
||||||
Profiler::ZoneEnd( m_id, QueueZoneEnd { GetTime() } );
|
Profiler::ZoneEnd( m_id, QueueZoneEnd { Profiler::GetTime() } );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user