Unravel Engine C++ Reference
Loading...
Searching...
No Matches
profiler.h File Reference
#include <engine/engine_export.h>
#include <chrono>
#include <cstdint>
#include <map>
#include <array>
#include <string>
#include <vector>
#include <memory>
#include <mutex>
#include <atomic>
#include <algorithm>
#include <type_traits>
#include <hpp/string_view.hpp>
#include <base/platform/thread.hpp>

Go to the source code of this file.

Classes

class  unravel::sample_data
 
struct  unravel::profile_event
 A single profiling event captured during a frame. More...
 
struct  unravel::thread_profile_buffer
 Fixed-size buffer of profile events for one frame on one thread. More...
 
struct  unravel::thread_profile_data
 Double-buffered per-thread profiling state. One buffer is being written by the owning thread while the other is read by the main thread for display and aggregation. More...
 
struct  unravel::frame_snapshot
 Compacted copy of one frame's profiling data across all threads. More...
 
struct  unravel::frame_snapshot::thread_snapshot
 
class  unravel::performance_profiler
 
struct  unravel::performance_profiler::per_frame_data
 Per-name aggregate timing data with rolling history. More...
 
struct  unravel::performance_profiler::thread_info
 
class  unravel::scope_profile_timer
 
class  unravel::scope_profile_timer_owned
 
class  unravel::scope_profile_timer_named_thread< ScopeName, ThreadName >
 Like scope_profile_timer but registers the current OS thread with ThreadName on first use. More...
 

Namespaces

namespace  unravel
 

Concepts

concept  unravel::string_literal
 Concept to ensure only string literals (char arrays) are accepted. With const T& parameter binding, T deduces as char[N].
 

Macros

#define APP_SCOPE_PERF_CONCATENATE_DETAIL(x, y)
 
#define APP_SCOPE_PERF_CONCATENATE(x, y)
 
#define APP_SCOPE_PERF_UNIQUE_VAR(prefix)
 
#define APP_SCOPE_PERF(name_literal)
 Create a scoped performance timer that records to the timeline profiler. Only accepts string literals to ensure pointer lifetime safety.
 
#define APP_SCOPE_PERF_OWNED(name)
 Create a scoped performance timer that records to the timeline profiler. Only accepts string literals to ensure pointer lifetime safety.
 
#define APP_SCOPE_PERF_THREAD(scope_name_literal, thread_name_literal)
 Scoped scope on a named thread lane (thread_name used only on first profiler use this thread).
 

Enumerations

enum class  unravel::recording_state : uint8_t { unravel::stopped , unravel::recording , unravel::paused }
 

Functions

constexpr auto unravel::fnv1a_hash (const char *str) -> uint32_t
 
auto unravel::profiler_process_capture_gate_ref () -> std::atomic< uint8_t > &
 
auto unravel::profiler_process_capture_gate_load () -> bool
 
void unravel::profiler_process_capture_gate_store (uint8_t v)
 
auto unravel::get_time_ns () -> int64_t
 
auto unravel::ensure_thread_registered (const char *thread_name=nullptr) -> thread_profile_data *
 Register the current thread on first use. thread_name if non-null and non-empty is stored as the lane label; otherwise "Thread-{id}" is used. Called at most once per thread (TLS).
 
auto unravel::get_thread_profile_data () -> thread_profile_data *
 
auto unravel::get_thread_profile_data (const char *thread_name) -> thread_profile_data *
 Resolve TLS data, registering with thread_name only if this is the first profiler use on this OS thread (subsequent calls ignore thread_name).
 
auto unravel::profile_begin (const char *name) -> uint32_t
 Begin a profiling scope. Returns an event index for profile_end().
 
auto unravel::profile_begin (const char *name, const char *thread_name) -> uint32_t
 Same as profile_begin(name), but the first profiler call on this thread uses thread_name for the timeline lane label (e.g. "Render" / "JobPool-3").
 
auto unravel::profile_begin_owned (hpp::string_view name) -> uint32_t
 Like profile_begin() but copies the label into name_owned (script / dynamic names).
 
auto unravel::profile_begin_owned (hpp::string_view name, const char *thread_name) -> uint32_t
 profile_begin_owned(name) with optional lane label on first registration (see profile_begin two-arg).
 
void unravel::profile_end (uint32_t idx)
 End a profiling scope started by profile_begin().
 
auto unravel::get_app_profiler () -> performance_profiler *
 

Variables

thread_local thread_profile_dataunravel::t_profile_data = nullptr
 

Macro Definition Documentation

◆ APP_SCOPE_PERF

#define APP_SCOPE_PERF ( name_literal)
Value:
const ::unravel::scope_profile_timer APP_SCOPE_PERF_UNIQUE_VAR(timer)(name_literal)
#define APP_SCOPE_PERF_UNIQUE_VAR(prefix)
Definition profiler.h:671

Create a scoped performance timer that records to the timeline profiler. Only accepts string literals to ensure pointer lifetime safety.

Definition at line 675 of file profiler.h.

◆ APP_SCOPE_PERF_CONCATENATE

#define APP_SCOPE_PERF_CONCATENATE ( x,
y )
Value:
float y
float x
#define APP_SCOPE_PERF_CONCATENATE_DETAIL(x, y)
Definition profiler.h:669

Definition at line 670 of file profiler.h.

◆ APP_SCOPE_PERF_CONCATENATE_DETAIL

#define APP_SCOPE_PERF_CONCATENATE_DETAIL ( x,
y )
Value:
x##y

Definition at line 669 of file profiler.h.

◆ APP_SCOPE_PERF_OWNED

#define APP_SCOPE_PERF_OWNED ( name)
Value:
const ::unravel::scope_profile_timer_owned APP_SCOPE_PERF_UNIQUE_VAR(timer)(name)
std::string name
Definition hub.cpp:33

Create a scoped performance timer that records to the timeline profiler. Only accepts string literals to ensure pointer lifetime safety.

Definition at line 680 of file profiler.h.

◆ APP_SCOPE_PERF_THREAD

#define APP_SCOPE_PERF_THREAD ( scope_name_literal,
thread_name_literal )
Value:
const ::unravel::scope_profile_timer_named_thread APP_SCOPE_PERF_UNIQUE_VAR(timer_thread)(scope_name_literal, \
thread_name_literal)

Scoped scope on a named thread lane (thread_name used only on first profiler use this thread).

Definition at line 684 of file profiler.h.

◆ APP_SCOPE_PERF_UNIQUE_VAR

#define APP_SCOPE_PERF_UNIQUE_VAR ( prefix)
Value:
APP_SCOPE_PERF_CONCATENATE(prefix, __LINE__)
#define APP_SCOPE_PERF_CONCATENATE(x, y)
Definition profiler.h:670

Definition at line 671 of file profiler.h.