tracy/client/TracyScoped.hpp

45 lines
856 B
C++
Raw Normal View History

2017-09-10 18:09:57 +00:00
#ifndef __TRACYSCOPED_HPP__
#define __TRACYSCOPED_HPP__
#include <stdint.h>
#include "../common/TracySystem.hpp"
2017-09-10 18:09:57 +00:00
#include "TracyProfiler.hpp"
namespace tracy
{
class ScopedZone
{
public:
ScopedZone( const SourceLocation* srcloc )
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)srcloc, GetThreadHandle() } ) )
2017-09-10 18:09:57 +00:00
{
}
~ScopedZone()
{
2017-09-23 19:09:46 +00:00
Profiler::ZoneEnd( m_id, QueueZoneEnd { Profiler::GetTime() } );
2017-09-10 18:09:57 +00:00
}
2017-09-27 00:18:17 +00:00
void Text( const char* txt, size_t size )
{
auto ptr = new char[size+1];
memcpy( ptr, txt, size );
ptr[size] = '\0';
Profiler::ZoneText( m_id, QueueZoneText { (uint64_t)ptr } );
}
2017-09-28 17:28:24 +00:00
void Name( const char* name )
{
Profiler::ZoneName( m_id, QueueZoneName { (uint64_t)name } );
}
2017-09-10 18:09:57 +00:00
private:
uint64_t m_id;
};
}
#endif