tracy/client/TracyProfiler.hpp

57 lines
1.0 KiB
C++
Raw Normal View History

2017-09-10 15:43:56 +00:00
#ifndef __TRACYPROFILER_HPP__
#define __TRACYPROFILER_HPP__
#include <atomic>
2017-09-10 18:08:42 +00:00
#include <stdint.h>
2017-09-10 15:43:56 +00:00
#include <thread>
#include "../common/tracy_lz4.hpp"
2017-09-13 20:56:08 +00:00
#include "../common/TracyQueue.hpp"
2017-09-10 18:09:14 +00:00
2017-09-10 15:43:56 +00:00
namespace tracy
{
class Socket;
2017-09-10 15:43:56 +00:00
class Profiler
{
public:
Profiler();
~Profiler();
2017-09-10 18:08:42 +00:00
static uint64_t GetNewId();
2017-09-23 19:09:46 +00:00
static int64_t GetTime();
2017-09-10 18:08:42 +00:00
static uint64_t ZoneBegin( QueueZoneBegin&& data );
static void ZoneEnd( uint64_t id, QueueZoneEnd&& data );
2017-09-15 22:30:27 +00:00
static void FrameMark();
2017-09-10 18:09:14 +00:00
static bool ShouldExit();
2017-09-10 15:43:56 +00:00
private:
void Worker();
bool SendData( const char* data, size_t len );
bool SendString( uint64_t ptr, const char* str, QueueType type );
bool HandleServerQuery();
2017-09-23 19:33:05 +00:00
void CalibrateTimer();
double m_timerMul;
2017-09-10 18:14:16 +00:00
int64_t m_timeBegin;
2017-09-22 23:37:07 +00:00
uint64_t m_mainThread;
2017-09-10 15:43:56 +00:00
std::thread m_thread;
std::atomic<bool> m_shutdown;
2017-09-10 18:08:42 +00:00
std::atomic<uint64_t> m_id;
std::unique_ptr<Socket> m_sock;
LZ4_stream_t* m_stream;
char* m_buffer;
int m_bufferOffset;
2017-09-10 15:43:56 +00:00
};
};
#endif