tracy/client/TracyScoped.hpp
Bartosz Taudul 7424077d70 Store source location in a single object.
Source file, function name and line number are now stored in a const
static container object. This has the following benefits:
- Slightly lighter profiling workload (3 instructions less).
- Profiling queue event size is significantly reduced, by 12 bytes. This
  has an effect on all queue event types.
- Source location grouping has now no cost, as it's performed at the
  compilation stage. This allows simplification of server code.
The downside is that the full source location resolution is now
performed in two steps, as the server has to query both source location
container and strings contained within. This has almost no real impact
on profiler operation.
2017-09-26 02:39:08 +02:00

32 lines
537 B
C++
Executable File

#ifndef __TRACYSCOPED_HPP__
#define __TRACYSCOPED_HPP__
#include <stdint.h>
#include "../common/TracySystem.hpp"
#include "TracyProfiler.hpp"
namespace tracy
{
class ScopedZone
{
public:
ScopedZone( const SourceLocation* srcloc, uint32_t color )
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)srcloc, GetThreadHandle(), color } ) )
{
}
~ScopedZone()
{
Profiler::ZoneEnd( m_id, QueueZoneEnd { Profiler::GetTime() } );
}
private:
uint64_t m_id;
};
}
#endif