the profiler
where a frame went, per zone
mirrored from
window/cpp/window.core/prof/README.md, which is the only copy of this text. edits made here are overwritten the next time the site builds
the base profiler out of D:\Desktop\engine\profiled\, stripped to the five files that produce a trace n
nothing else. P1.C.1, see plan/PLAN.C.perf-pass.md
header only, five files, no dependency outside itself n the standard library. copied 2026-09-10
| file | what it is |
|---|---|
zone.h | one profile_zone_t, a name n a start n an end n a depth n a colour |
profiler.h | profiler_t, the static facade over a thread_local thread_profile_t |
scoper.h | profile_scope_t n the PROFILE_FUNCTION() / PROFILE_SCOPE("name") macros |
collector.h | profiler_collector_t, cross thread aggregation under one mutex |
session.h | prof::session_t, the lifecycle n the chrome trace writer |
whats deliberately not here
imgui.cpp, the live flame graph. finns call 2026-09-10, the trace is what we actually need n there is no imgui in this tree. the trace opens inui.perfetto.devorchrome://tracingprof.hnexport.cpp, the OLD standalone exporter.session_t::export_chromealready writes the trace n writes a better one,export.cpphardcodespidntidto 0 where the session tags the real thread n emits theph:"M"thread_name records beside it. dropping the pair also takes theprint.hdependency with it, which is why this folder needs nothing outside the standard library- the testbed,
job_system.hnjob_deque.hnjunk.hnmain.cppnprint.h. that is the work stealing job system the profiler was written against, it stays in its own project
using it
#include "prof/session.h"
#include "prof/scoper.h"
void paint_subtree()
{
PROFILE_FUNCTION();
// ...
}
prof::session_t session; // stamps the start, clears this threads buffer
// ... run frames ...
session.export_chrome("trace.json");a zone name is BORROWED, it is a std::string_view. a literal n __FUNCTION__ are both static n
fine, a composed one has to be held somewhere that outlives the zone or it dangles. changed at source
2026-09-10, finns call, bc on msvc __FUNCTION__ in a member gives the class qualified name n
control_t::paint_subtree is well past the 15 char sso buffer, so every zone on a paint path was taking a
heap allocation to store a name it never owned
the macros vanish unless _DEBUG or ENGINE_PROFILING_ENABLED is defined, so a release build carries
no trace of them rather than switching them off, the same bargain P1.41 makes with the debug dll
what is proven, n what is not
the five build at /W4 /WX in three configs, all exit 0, measured 2026-09-10 with a probe TU, Debug
with zones on, Release with them compiled out, n Release with them forced on. that covers a
PROFILE_FUNCTION() on a member, a literal name, n a view into a held string
nothing has been RUN yet n nothing is wired, no zone is in any window source, the folder is in no
.vcxproj, n no trace has been written out of this tree. that is the rest of P1.C.1 n P1.C.2
the summariser cannot read a chrome trace yet. .claude/stack/cpp/run-profiler.nu wants aggregated
rows of zone n calls n self_ms n total_ms where a trace is one row per zone INSTANCE with no self
time, so it needs a chrome branch in read-capture, which is the real work left in P1.C.1