Hide GetTime() in Profiler.

This commit is contained in:
Bartosz Taudul 2017-09-23 21:09:46 +02:00
parent c0b1846a35
commit bd9ffc16b5
3 changed files with 9 additions and 8 deletions

View File

@ -5,6 +5,7 @@
#endif
#include <assert.h>
#include <chrono>
#include <limits>
#include <memory>
#include <string.h>
@ -71,6 +72,11 @@ uint64_t Profiler::GetNewId()
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 )
{
auto id = GetNewId();

View File

@ -2,7 +2,6 @@
#define __TRACYPROFILER_HPP__
#include <atomic>
#include <chrono>
#include <stdint.h>
#include <thread>
@ -14,11 +13,6 @@ namespace tracy
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
{
public:
@ -26,6 +20,7 @@ public:
~Profiler();
static uint64_t GetNewId();
static int64_t GetTime();
static uint64_t ZoneBegin( QueueZoneBegin&& data );
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );

View File

@ -13,13 +13,13 @@ class ScopedZone
{
public:
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()
{
Profiler::ZoneEnd( m_id, QueueZoneEnd { GetTime() } );
Profiler::ZoneEnd( m_id, QueueZoneEnd { Profiler::GetTime() } );
}
private: