window

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

filewhat it is
zone.hone profile_zone_t, a name n a start n an end n a depth n a colour
profiler.hprofiler_t, the static facade over a thread_local thread_profile_t
scoper.hprofile_scope_t n the PROFILE_FUNCTION() / PROFILE_SCOPE("name") macros
collector.hprofiler_collector_t, cross thread aggregation under one mutex
session.hprof::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 in ui.perfetto.dev or chrome://tracing
  • prof.h n export.cpp, the OLD standalone exporter. session_t::export_chrome already writes the trace n writes a better one, export.cpp hardcodes pid n tid to 0 where the session tags the real thread n emits the ph:"M" thread_name records beside it. dropping the pair also takes the print.h dependency with it, which is why this folder needs nothing outside the standard library
  • the testbed, job_system.h n job_deque.h n junk.h n main.cpp n print.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

On this page