Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::performance_profiler Class Reference

#include <profiler.h>

Classes

struct  per_frame_data
 Per-name aggregate timing data with rolling history. More...
 
struct  thread_info
 

Public Types

using record_data_t = std::map<std::string, per_frame_data, std::less<>>
 

Public Member Functions

void add_record (hpp::string_view name, float time_ms)
 Script / external pre-measured span on the current thread: same as profile_begin_owned + profile_end, then wall/CPU times set to [now - time_ms, now]. Thread must already be registered (e.g. native code or prior ensure_thread_registered).
 
void swap ()
 End-of-frame: flip buffers, compute aggregates, advance history.
 
auto get_per_frame_data_read () const -> const record_data_t &
 Aggregate per-name data for the statistics panel.
 
auto register_thread (const std::string &name) -> thread_profile_data *
 Register the calling thread for timeline profiling.
 
auto get_threads () const -> const std::vector< thread_info > &
 All registered threads and their profiling data.
 
auto get_frame_start_ns () const -> int64_t
 Frame boundary timestamps for the last completed frame.
 
auto get_frame_end_ns () const -> int64_t
 
void set_recording_state (recording_state state)
 Recording control.
 
auto get_recording_state () const -> recording_state
 
auto get_frame_count () const -> uint32_t
 Number of captured frame snapshots available.
 
auto get_frame_snapshot (uint32_t index) const -> const frame_snapshot *
 Access a captured frame snapshot.
 
void set_selected_frame (int32_t index)
 Selected frame index for UI inspection (-1 = live/latest).
 
auto get_selected_frame () const -> int32_t
 
void clear_history ()
 Clear all captured frame history.
 
auto get_max_frame_history () const -> uint32_t
 Current frame-history ring capacity.
 
void set_max_frame_history (uint32_t capacity)
 Resize history capacity, keeping the newest frames when shrinking.
 

Static Public Attributes

static constexpr uint32_t max_frame_history_limit = 2000
 Absolute upper bound for set_max_frame_history.
 
static constexpr uint32_t default_frame_history = 256
 Default ring-buffer capacity (keeps histogram/UI cost bounded).
 
static constexpr uint32_t min_frame_history = 64
 Minimum allowed capacity.
 

Detailed Description

Definition at line 240 of file profiler.h.

Member Typedef Documentation

◆ record_data_t

using unravel::performance_profiler::record_data_t = std::map<std::string, per_frame_data, std::less<>>

Definition at line 288 of file profiler.h.

Member Function Documentation

◆ add_record()

void unravel::performance_profiler::add_record ( hpp::string_view name,
float time_ms )

Script / external pre-measured span on the current thread: same as profile_begin_owned + profile_end, then wall/CPU times set to [now - time_ms, now]. Thread must already be registered (e.g. native code or prior ensure_thread_registered).

Definition at line 142 of file profiler.cpp.

◆ clear_history()

void unravel::performance_profiler::clear_history ( )

Clear all captured frame history.

Definition at line 423 of file profiler.cpp.

◆ get_frame_count()

auto unravel::performance_profiler::get_frame_count ( ) const -> uint32_t

Number of captured frame snapshots available.

Definition at line 351 of file profiler.cpp.

◆ get_frame_end_ns()

auto unravel::performance_profiler::get_frame_end_ns ( ) const -> int64_t

Definition at line 324 of file profiler.cpp.

◆ get_frame_snapshot()

auto unravel::performance_profiler::get_frame_snapshot ( uint32_t index) const -> const frame_snapshot*

Access a captured frame snapshot.

Parameters
index0 = oldest captured, get_frame_count()-1 = newest.

Definition at line 356 of file profiler.cpp.

◆ get_frame_start_ns()

auto unravel::performance_profiler::get_frame_start_ns ( ) const -> int64_t

Frame boundary timestamps for the last completed frame.

Definition at line 319 of file profiler.cpp.

◆ get_max_frame_history()

auto unravel::performance_profiler::get_max_frame_history ( ) const -> uint32_t
nodiscard

Current frame-history ring capacity.

Definition at line 382 of file profiler.cpp.

◆ get_per_frame_data_read()

auto unravel::performance_profiler::get_per_frame_data_read ( ) const -> const record_data_t&

Aggregate per-name data for the statistics panel.

Definition at line 309 of file profiler.cpp.

◆ get_recording_state()

auto unravel::performance_profiler::get_recording_state ( ) const -> recording_state

Definition at line 346 of file profiler.cpp.

◆ get_selected_frame()

auto unravel::performance_profiler::get_selected_frame ( ) const -> int32_t

Definition at line 377 of file profiler.cpp.

◆ get_threads()

auto unravel::performance_profiler::get_threads ( ) const -> const std::vector<thread_info>&

All registered threads and their profiling data.

Definition at line 314 of file profiler.cpp.

◆ register_thread()

auto unravel::performance_profiler::register_thread ( const std::string & name) -> thread_profile_data*

Register the calling thread for timeline profiling.

Returns
Pointer to the thread's profiling data (stable for the thread's lifetime).

Definition at line 136 of file profiler.cpp.

◆ set_max_frame_history()

void unravel::performance_profiler::set_max_frame_history ( uint32_t capacity)

Resize history capacity, keeping the newest frames when shrinking.

Definition at line 387 of file profiler.cpp.

◆ set_recording_state()

void unravel::performance_profiler::set_recording_state ( recording_state state)

Recording control.

Definition at line 335 of file profiler.cpp.

◆ set_selected_frame()

void unravel::performance_profiler::set_selected_frame ( int32_t index)

Selected frame index for UI inspection (-1 = live/latest).

Definition at line 372 of file profiler.cpp.

◆ swap()

void unravel::performance_profiler::swap ( )

End-of-frame: flip buffers, compute aggregates, advance history.

Definition at line 174 of file profiler.cpp.

Member Data Documentation

◆ default_frame_history

uint32_t unravel::performance_profiler::default_frame_history = 256
staticconstexpr

Default ring-buffer capacity (keeps histogram/UI cost bounded).

Definition at line 339 of file profiler.h.

◆ max_frame_history_limit

uint32_t unravel::performance_profiler::max_frame_history_limit = 2000
staticconstexpr

Absolute upper bound for set_max_frame_history.

Definition at line 337 of file profiler.h.

◆ min_frame_history

uint32_t unravel::performance_profiler::min_frame_history = 64
staticconstexpr

Minimum allowed capacity.

Definition at line 341 of file profiler.h.


The documentation for this class was generated from the following files: