mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Add possibility to explicitly avoid logging
This commit is contained in:
parent
c4ea13dab5
commit
076e83635b
71
Tracy.hpp
71
Tracy.hpp
@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
#ifndef TRACY_ENABLE
|
#ifndef TRACY_ENABLE
|
||||||
|
|
||||||
#define ZoneNamed(x)
|
#define ZoneNamed(x,y)
|
||||||
#define ZoneNamedN(x,y)
|
#define ZoneNamedN(x,y,z)
|
||||||
#define ZoneNamedC(x,y)
|
#define ZoneNamedC(x,y,z)
|
||||||
#define ZoneNamedNC(x,y,z)
|
#define ZoneNamedNC(x,y,z,w)
|
||||||
|
|
||||||
#define ZoneScoped
|
#define ZoneScoped
|
||||||
#define ZoneScopedN(x)
|
#define ZoneScopedN(x)
|
||||||
@ -59,15 +59,20 @@
|
|||||||
#include "client/TracyProfiler.hpp"
|
#include "client/TracyProfiler.hpp"
|
||||||
#include "client/TracyScoped.hpp"
|
#include "client/TracyScoped.hpp"
|
||||||
|
|
||||||
#define ZoneNamed( varname ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__) );
|
#define ZoneNamed( varname, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
|
||||||
#define ZoneNamedN( varname, name ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__) );
|
#define ZoneNamedN( varname, name, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
|
||||||
#define ZoneNamedC( varname, color ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__) );
|
#define ZoneNamedC( varname, color, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
|
||||||
#define ZoneNamedNC( varname, name, color ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__) );
|
#define ZoneNamedNC( varname, name, color, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
|
||||||
|
|
||||||
#define ZoneScoped ZoneNamed( ___tracy_scoped_zone )
|
#define ZoneScoped ZoneNamed( ___tracy_scoped_zone, true )
|
||||||
#define ZoneScopedN( name ) ZoneNamedN( ___tracy_scoped_zone, name )
|
#define ZoneScopedN( name ) ZoneNamedN( ___tracy_scoped_zone, name, true )
|
||||||
#define ZoneScopedC( color ) ZoneNamedC( ___tracy_scoped_zone, color )
|
#define ZoneScopedC( color ) ZoneNamedC( ___tracy_scoped_zone, color, true )
|
||||||
#define ZoneScopedNC( name, color ) ZoneNamedNC( ___tracy_scoped_zone, name, color )
|
#define ZoneScopedNC( name, color ) ZoneNamedNC( ___tracy_scoped_zone, name, color, true )
|
||||||
|
|
||||||
|
#define ZoneScopedA( active ) ZoneNamed( ___tracy_scoped_zone, active )
|
||||||
|
#define ZoneScopedNA( name, active ) ZoneNamedN( ___tracy_scoped_zone, name, active )
|
||||||
|
#define ZoneScopedCA( color, active ) ZoneNamedC( ___tracy_scoped_zone, color, active )
|
||||||
|
#define ZoneScopedNCA( name, color, active ) ZoneNamedNC( ___tracy_scoped_zone, name, color, active )
|
||||||
|
|
||||||
#define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
|
#define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
|
||||||
#define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );
|
#define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );
|
||||||
@ -94,28 +99,38 @@
|
|||||||
#define TracyFree( ptr ) tracy::Profiler::MemFree( ptr );
|
#define TracyFree( ptr ) tracy::Profiler::MemFree( ptr );
|
||||||
|
|
||||||
#ifdef TRACY_HAS_CALLSTACK
|
#ifdef TRACY_HAS_CALLSTACK
|
||||||
# define ZoneNamedS( varname, depth ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth );
|
# define ZoneNamedS( varname, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
|
||||||
# define ZoneNamedNS( varname, name, depth ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth );
|
# define ZoneNamedNS( varname, name, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
|
||||||
# define ZoneNamedCS( varname, color, depth ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth );
|
# define ZoneNamedCS( varname, color, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
|
||||||
# define ZoneNamedNCS( varname, name, color, depth ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth );
|
# define ZoneNamedNCS( varname, name, color, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
|
||||||
|
|
||||||
# define ZoneScopedS( depth ) ZoneNamedS( ___tracy_scoped_zone, depth )
|
# define ZoneScopedS( depth ) ZoneNamedS( ___tracy_scoped_zone, depth, true )
|
||||||
# define ZoneScopedNS( name, depth ) ZoneNamedNS( ___tracy_scoped_zone, name, depth )
|
# define ZoneScopedNS( name, depth ) ZoneNamedNS( ___tracy_scoped_zone, name, depth, true )
|
||||||
# define ZoneScopedCS( color, depth ) ZoneNamedCS( ___tracy_scoped_zone, color, depth )
|
# define ZoneScopedCS( color, depth ) ZoneNamedCS( ___tracy_scoped_zone, color, depth, true )
|
||||||
# define ZoneScopedNCS( name, color, depth ) ZoneNamedNCS( ___tracy_scoped_zone, name, color depth )
|
# define ZoneScopedNCS( name, color, depth ) ZoneNamedNCS( ___tracy_scoped_zone, name, color depth, true )
|
||||||
|
|
||||||
|
# define ZoneScopedSA( depth, active ) ZoneNamedS( ___tracy_scoped_zone, depth, active )
|
||||||
|
# define ZoneScopedNSA( name, depth, active ) ZoneNamedNS( ___tracy_scoped_zone, name, depth, active )
|
||||||
|
# define ZoneScopedCSA( color, depth, active ) ZoneNamedCS( ___tracy_scoped_zone, color, depth, active )
|
||||||
|
# define ZoneScopedNCSA( name, color, depth, active ) ZoneNamedNCS( ___tracy_scoped_zone, name, color depth, active )
|
||||||
|
|
||||||
# define TracyAllocS( ptr, size, depth ) tracy::Profiler::MemAllocCallstack( ptr, size, depth );
|
# define TracyAllocS( ptr, size, depth ) tracy::Profiler::MemAllocCallstack( ptr, size, depth );
|
||||||
# define TracyFreeS( ptr, depth ) tracy::Profiler::MemFreeCallstack( ptr, depth );
|
# define TracyFreeS( ptr, depth ) tracy::Profiler::MemFreeCallstack( ptr, depth );
|
||||||
#else
|
#else
|
||||||
# define ZoneNamedS( varname, depth ) ZoneNamed( varname )
|
# define ZoneNamedS( varname, depth, active ) ZoneNamed( varname, active )
|
||||||
# define ZoneNamedNS( varname, name, depth ) ZoneNamedN( varname, name )
|
# define ZoneNamedNS( varname, name, depth, active ) ZoneNamedN( varname, name, active )
|
||||||
# define ZoneNamedCS( varname, color, depth ) ZoneNamedC( varname, color )
|
# define ZoneNamedCS( varname, color, depth, active ) ZoneNamedC( varname, color, active )
|
||||||
# define ZoneNamedNCS( varname, name, color, depth ) ZoneNamedNC( varname, name, color )
|
# define ZoneNamedNCS( varname, name, color, depth, active ) ZoneNamedNC( varname, name, color, active )
|
||||||
|
|
||||||
# define ZoneScopedS( depth ) ZoneScoped
|
# define ZoneScopedS( depth ) ZoneScoped( depth, true )
|
||||||
# define ZoneScopedNS( name, depth ) ZoneScopedN( name )
|
# define ZoneScopedNS( name, depth ) ZoneScopedN( name, true )
|
||||||
# define ZoneScopedCS( color, depth ) ZoneScopedC( color )
|
# define ZoneScopedCS( color, depth ) ZoneScopedC( color, true )
|
||||||
# define ZoneScopedNCS( name, color, depth ) ZoneScopedNC( name, color )
|
# define ZoneScopedNCS( name, color, depth ) ZoneScopedNC( name, color, true )
|
||||||
|
|
||||||
|
# define ZoneScopedSA( depth, active ) ZoneScoped( depth, active )
|
||||||
|
# define ZoneScopedNSA( name, depth, active ) ZoneScopedN( name, active )
|
||||||
|
# define ZoneScopedCSA( color, depth, active ) ZoneScopedC( color, active )
|
||||||
|
# define ZoneScopedNCSA( name, color, depth, active ) ZoneScopedNC( name, color, active )
|
||||||
|
|
||||||
# define TracyAllocS( ptr, size, depth ) TracyAlloc( ptr, size )
|
# define TracyAllocS( ptr, size, depth ) TracyAlloc( ptr, size )
|
||||||
# define TracyFreeS( ptr, depth ) TracyFree( ptr )
|
# define TracyFreeS( ptr, depth ) TracyFree( ptr )
|
||||||
|
@ -15,14 +15,14 @@ namespace tracy
|
|||||||
class ScopedZone
|
class ScopedZone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tracy_force_inline ScopedZone( const SourceLocationData* srcloc )
|
tracy_force_inline ScopedZone( const SourceLocationData* srcloc, bool is_active = true )
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
: m_active( s_profiler.IsConnected() )
|
: m_active( s_profiler.IsConnected() )
|
||||||
|
#else
|
||||||
|
: m_active( is_active )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#endif
|
|
||||||
const auto thread = GetThreadHandle();
|
const auto thread = GetThreadHandle();
|
||||||
m_thread = thread;
|
m_thread = thread;
|
||||||
Magic magic;
|
Magic magic;
|
||||||
@ -42,14 +42,14 @@ public:
|
|||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline ScopedZone( const SourceLocationData* srcloc, int depth )
|
tracy_force_inline ScopedZone( const SourceLocationData* srcloc, int depth, bool is_active = true )
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
: m_active( s_profiler.IsConnected() )
|
: m_active( s_profiler.IsConnected() )
|
||||||
|
#else
|
||||||
|
: m_active( is_active )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#endif
|
|
||||||
const auto thread = GetThreadHandle();
|
const auto thread = GetThreadHandle();
|
||||||
m_thread = thread;
|
m_thread = thread;
|
||||||
Magic magic;
|
Magic magic;
|
||||||
@ -73,9 +73,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline ~ScopedZone()
|
tracy_force_inline ~ScopedZone()
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#endif
|
|
||||||
Magic magic;
|
Magic magic;
|
||||||
auto& token = s_token.ptr;
|
auto& token = s_token.ptr;
|
||||||
auto& tail = token->get_tail_index();
|
auto& tail = token->get_tail_index();
|
||||||
@ -94,9 +92,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Text( const char* txt, size_t size )
|
tracy_force_inline void Text( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#endif
|
|
||||||
Magic magic;
|
Magic magic;
|
||||||
auto& token = s_token.ptr;
|
auto& token = s_token.ptr;
|
||||||
auto ptr = (char*)tracy_malloc( size+1 );
|
auto ptr = (char*)tracy_malloc( size+1 );
|
||||||
@ -112,9 +108,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Name( const char* txt, size_t size )
|
tracy_force_inline void Name( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#endif
|
|
||||||
Magic magic;
|
Magic magic;
|
||||||
auto& token = s_token.ptr;
|
auto& token = s_token.ptr;
|
||||||
auto ptr = (char*)tracy_malloc( size+1 );
|
auto ptr = (char*)tracy_malloc( size+1 );
|
||||||
@ -130,10 +124,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t m_thread;
|
uint64_t m_thread;
|
||||||
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
const bool m_active;
|
const bool m_active;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user