tracy/client/TracyProfiler.hpp
2017-09-18 18:51:45 +02:00

56 lines
1.0 KiB
C++
Executable File

#ifndef __TRACYPROFILER_HPP__
#define __TRACYPROFILER_HPP__
#include <atomic>
#include <chrono>
#include <stdint.h>
#include <thread>
#include "../common/tracy_lz4.hpp"
#include "../common/TracyQueue.hpp"
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:
Profiler();
~Profiler();
static uint64_t GetNewId();
static uint64_t ZoneBegin( QueueZoneBegin&& data );
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );
static void FrameMark();
static bool ShouldExit();
private:
void Worker();
bool SendData( const char* data, size_t len );
bool SendString( uint64_t ptr );
int64_t m_timeBegin;
std::thread m_thread;
std::atomic<bool> m_shutdown;
std::atomic<uint64_t> m_id;
std::unique_ptr<Socket> m_sock;
LZ4_stream_t* m_stream;
char* m_buffer;
int m_bufferOffset;
};
};
#endif