Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::profile::Backend Class Referenceabstract

Abstract profiler backend interface. More...

#include <backend.hpp>

Inheritance diagram for helios::profile::Backend:
helios::profile::FlamegraphBackend helios::profile::TracyBackend

Public Member Functions

virtual ~Backend () noexcept=default
virtual void Startup () noexcept
 Called once after finalization (single-threaded).
virtual void Shutdown () noexcept
 Called during shutdown (single-threaded).
virtual size_t ZoneStorageSize () const noexcept=0
 Returns the per-zone storage required by this backend.
virtual void BeginZone (const ZoneSpec &spec, std::span< std::byte > storage) noexcept=0
 Begins a profiling zone.
virtual void EndZone (std::span< std::byte > storage) noexcept=0
 Ends a profiling zone.
virtual void ZoneText (std::span< std::byte > storage, std::string_view text) noexcept=0
 Attaches text to the active zone.
virtual void ZoneValue (std::span< std::byte > storage, uint64_t value) noexcept=0
 Attaches a numeric value to the active zone.
virtual void ZoneName (std::span< std::byte > storage, std::string_view name) noexcept=0
 Renames the active zone.
virtual void FrameMark () noexcept=0
 Marks the end of the current frame.
virtual void FrameMark (CStringView name) noexcept=0
 Marks the end of a named frame.
virtual void FrameMarkStart (CStringView name) noexcept=0
 Marks the start of a named frame region.
virtual void FrameMarkEnd (CStringView name) noexcept=0
 Marks the end of a named frame region.
virtual void Message (std::string_view text, uint32_t color) noexcept=0
 Emits a timeline message.
virtual void SetThreadName (CStringView name) noexcept=0
 Sets the current thread name.
virtual void Plot (CStringView name, double value) noexcept=0
 Records a plot sample.
virtual void PlotConfig (CStringView name, PlotFormat type, bool step, bool fill, uint32_t color) noexcept=0
 Configures a plot channel.
virtual void Alloc (const void *ptr, size_t size, std::optional< CStringView > name, int depth, std::source_location loc) noexcept=0
 Records a memory allocation.
virtual void Free (const void *ptr, std::optional< CStringView > name, int depth, std::source_location loc) noexcept=0
 Records a memory deallocation.
virtual void MemoryDiscard (CStringView name) noexcept=0
 Discards tracked memory for a named pool.
virtual void MemoryDiscard (CStringView name, int depth) noexcept=0
 Discards tracked memory for a named pool with callstack depth.
virtual std::string_view Name () const noexcept=0
 Returns the backend name.

Detailed Description

Abstract profiler backend interface.

Each backend receives a slice of ScopedZone storage sized by ZoneStorageSize(). Backends adapt Helios profiling concepts (zones, frames, counters, memory events) to their native representation.

Thread-safety contract:

Definition at line 30 of file backend.hpp.

Constructor & Destructor Documentation

◆ ~Backend()

virtual helios::profile::Backend::~Backend ( )
virtualdefaultnoexcept

Member Function Documentation

◆ Alloc()

virtual void helios::profile::Backend::Alloc ( const void * ptr,
size_t size,
std::optional< CStringView > name,
int depth,
std::source_location loc )
pure virtualnoexcept

Records a memory allocation.

Parameters
ptrAllocated pointer
sizeAllocation size
nameOptional allocation pool name
depthCallstack depth
locSource location

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ BeginZone()

virtual void helios::profile::Backend::BeginZone ( const ZoneSpec & spec,
std::span< std::byte > storage )
pure virtualnoexcept

Begins a profiling zone.

Parameters
specZone specification
storageBackend-specific storage slice

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ EndZone()

virtual void helios::profile::Backend::EndZone ( std::span< std::byte > storage)
pure virtualnoexcept

Ends a profiling zone.

Parameters
storageBackend-specific storage slice

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ FrameMark() [1/2]

virtual void helios::profile::Backend::FrameMark ( )
pure virtualnoexcept

Marks the end of the current frame.

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ FrameMark() [2/2]

virtual void helios::profile::Backend::FrameMark ( CStringView name)
pure virtualnoexcept

Marks the end of a named frame.

Parameters
nameFrame name

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ FrameMarkEnd()

virtual void helios::profile::Backend::FrameMarkEnd ( CStringView name)
pure virtualnoexcept

Marks the end of a named frame region.

Parameters
nameFrame region name

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ FrameMarkStart()

virtual void helios::profile::Backend::FrameMarkStart ( CStringView name)
pure virtualnoexcept

Marks the start of a named frame region.

Parameters
nameFrame region name

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ Free()

virtual void helios::profile::Backend::Free ( const void * ptr,
std::optional< CStringView > name,
int depth,
std::source_location loc )
pure virtualnoexcept

Records a memory deallocation.

Parameters
ptrDeallocated pointer
nameOptional allocation pool name
depthCallstack depth
locSource location

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ MemoryDiscard() [1/2]

virtual void helios::profile::Backend::MemoryDiscard ( CStringView name)
pure virtualnoexcept

Discards tracked memory for a named pool.

Parameters
namePool name

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ MemoryDiscard() [2/2]

virtual void helios::profile::Backend::MemoryDiscard ( CStringView name,
int depth )
pure virtualnoexcept

Discards tracked memory for a named pool with callstack depth.

Parameters
namePool name
depthCallstack depth

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ Message()

virtual void helios::profile::Backend::Message ( std::string_view text,
uint32_t color )
pure virtualnoexcept

Emits a timeline message.

Parameters
textMessage text
colorOptional message color

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ Name()

virtual std::string_view helios::profile::Backend::Name ( ) const
nodiscardpure virtualnoexcept

Returns the backend name.

Returns
Backend identifier

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ Plot()

virtual void helios::profile::Backend::Plot ( CStringView name,
double value )
pure virtualnoexcept

Records a plot sample.

Parameters
namePlot channel name
valueSample value

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ PlotConfig()

virtual void helios::profile::Backend::PlotConfig ( CStringView name,
PlotFormat type,
bool step,
bool fill,
uint32_t color )
pure virtualnoexcept

Configures a plot channel.

Parameters
namePlot channel name
typePlot value format
stepWhether the plot is step-wise
fillWhether the plot is filled
colorPlot color

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ SetThreadName()

virtual void helios::profile::Backend::SetThreadName ( CStringView name)
pure virtualnoexcept

Sets the current thread name.

Parameters
nameThread name

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ Shutdown()

virtual void helios::profile::Backend::Shutdown ( )
inlinevirtualnoexcept

Called during shutdown (single-threaded).

Reimplemented in helios::profile::FlamegraphBackend.

Definition at line 39 of file backend.hpp.

◆ Startup()

virtual void helios::profile::Backend::Startup ( )
inlinevirtualnoexcept

Called once after finalization (single-threaded).

Reimplemented in helios::profile::FlamegraphBackend.

Definition at line 35 of file backend.hpp.

◆ ZoneName()

virtual void helios::profile::Backend::ZoneName ( std::span< std::byte > storage,
std::string_view name )
pure virtualnoexcept

Renames the active zone.

Parameters
storageBackend-specific storage slice
nameNew zone name

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ ZoneStorageSize()

virtual size_t helios::profile::Backend::ZoneStorageSize ( ) const
nodiscardpure virtualnoexcept

Returns the per-zone storage required by this backend.

Returns
Storage size in bytes

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ ZoneText()

virtual void helios::profile::Backend::ZoneText ( std::span< std::byte > storage,
std::string_view text )
pure virtualnoexcept

Attaches text to the active zone.

Parameters
storageBackend-specific storage slice
textText to attach

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.

◆ ZoneValue()

virtual void helios::profile::Backend::ZoneValue ( std::span< std::byte > storage,
uint64_t value )
pure virtualnoexcept

Attaches a numeric value to the active zone.

Parameters
storageBackend-specific storage slice
valueValue to attach

Implemented in helios::profile::FlamegraphBackend, and helios::profile::TracyBackend.