docs
Loading...
Searching...
No Matches
CAPI_Profiler.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5
6///
7/// @file CAPI_Profiler.h
8///
9/// User-defined profiling interface.
10///
11/// `#include <Ultralight/CAPI/CAPI_Profiler.h>`
12///
13/// When set, the library emits structured timing data (scopes, events, counters) at key
14/// internal boundaries that can be forwarded to any profiling tool or trace format.
15///
16/// This is intended to be implemented by users and set before creating the Renderer.
17/// The profiler must outlive the Renderer/App.
18///
19/// @see ulPlatformSetProfiler()
20///
21#ifndef ULTRALIGHT_CAPI_PROFILER_H
22#define ULTRALIGHT_CAPI_PROFILER_H
23
25
26#if UL_HAS(PROFILER)
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/******************************************************************************
33 * Profiler
34 *****************************************************************************/
35
36///
37/// The callback invoked when the library enters a named profiling scope.
38///
39/// @param name Static string literal identifying the scope (e.g., "Ultralight.Layout").
40/// Pointer is stable for the lifetime of the library.
41///
42typedef void (*ULProfilerBeginScopeCallback)(const char* name);
43
44///
45/// The callback invoked when the library exits the most recently entered scope.
46///
47typedef void (*ULProfilerEndScopeCallback)(void);
48
49///
50/// The callback invoked when a new rendering frame begins.
51/// Called automatically by the library.
52///
53/// @param frame_id Monotonic frame counter.
54///
55typedef void (*ULProfilerBeginFrameCallback)(uint64_t frame_id);
56
57///
58/// The callback invoked when a rendering frame ends.
59/// Called automatically by the library.
60///
61typedef void (*ULProfilerEndFrameCallback)(void);
62
63///
64/// The callback invoked for instant (point-in-time) annotations.
65///
66/// @param name Static string literal identifying the event.
67/// @param detail Optional detail string (may be NULL).
68///
69typedef void (*ULProfilerEmitEventCallback)(const char* name, const char* detail);
70
71///
72/// The callback invoked for counter/gauge updates.
73///
74/// @param name Static string literal identifying the counter.
75/// @param value Current value of the counter.
76///
77typedef void (*ULProfilerEmitCounterCallback)(const char* name, int64_t value);
78
79///
80/// The callback invoked when an async event begins.
81///
82/// @param name Static string literal identifying the event type.
83/// @param detail Optional detail string (may be NULL).
84///
85/// @return Implementation-defined event ID (passed to end_event to close). Must be non-zero.
86///
87typedef uint64_t (*ULProfilerBeginEventCallback)(const char* name, const char* detail);
88
89///
90/// The callback invoked when an async event ends.
91///
92/// @param id The event ID returned by begin_event.
93///
94typedef void (*ULProfilerEndEventCallback)(uint64_t id);
95
106
107#ifdef __cplusplus
108} // extern "C"
109#endif
110
111#endif // UL_HAS(PROFILER)
112
113#endif // ULTRALIGHT_CAPI_PROFILER_H
void(*) ULProfilerEmitEventCallback(const char *name, const char *detail)
The callback invoked for instant (point-in-time) annotations.
Definition CAPI_Profiler.h:69
void(*) ULProfilerEndFrameCallback(void)
The callback invoked when a rendering frame ends.
Definition CAPI_Profiler.h:61
void(*) ULProfilerEndEventCallback(uint64_t id)
The callback invoked when an async event ends.
Definition CAPI_Profiler.h:94
void(*) ULProfilerEmitCounterCallback(const char *name, int64_t value)
The callback invoked for counter/gauge updates.
Definition CAPI_Profiler.h:77
void(*) ULProfilerEndScopeCallback(void)
The callback invoked when the library exits the most recently entered scope.
Definition CAPI_Profiler.h:47
uint64_t(*) ULProfilerBeginEventCallback(const char *name, const char *detail)
The callback invoked when an async event begins.
Definition CAPI_Profiler.h:87
void(*) ULProfilerBeginFrameCallback(uint64_t frame_id)
The callback invoked when a new rendering frame begins.
Definition CAPI_Profiler.h:55
void(*) ULProfilerBeginScopeCallback(const char *name)
The callback invoked when the library enters a named profiling scope.
Definition CAPI_Profiler.h:42
Various defines and utility functions for the C API.
Definition CAPI_Profiler.h:96
ULProfilerBeginFrameCallback begin_frame
May be NULL.
Definition CAPI_Profiler.h:99
ULProfilerEmitEventCallback emit_event
Definition CAPI_Profiler.h:101
ULProfilerEndFrameCallback end_frame
May be NULL.
Definition CAPI_Profiler.h:100
ULProfilerEndScopeCallback end_scope
Definition CAPI_Profiler.h:98
ULProfilerEndEventCallback end_event
Definition CAPI_Profiler.h:104
ULProfilerBeginScopeCallback begin_scope
Definition CAPI_Profiler.h:97
ULProfilerBeginEventCallback begin_event
Definition CAPI_Profiler.h:103
ULProfilerEmitCounterCallback emit_counter
Definition CAPI_Profiler.h:102