group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Profiler.cpp File Reference

Profiler runtime: scope registration, sample recording, 1 Hz aggregator thread. More...

#include "Profiler.hpp"
#include <SDL3/SDL.h>
#include <algorithm>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <mutex>
#include <thread>
Include dependency graph for Profiler.cpp:

Namespaces

namespace  group2
namespace  group2::perf

Functions

ScopeId group2::perf::registerScope (const char *name)
 Register (or look up) a scope name and return its dense id.
const char * group2::perf::scopeName (ScopeId id)
 Returns the human-readable name a ScopeId was registered with, or "" if id is out of range.
std::size_t group2::perf::scopeCount ()
 Returns the highest registered id + 1.
void group2::perf::recordSample (ScopeId id, std::uint64_t ticks) noexcept
 Recording entry point — public so unit tests can invoke it directly without a real ScopeTimer.
void group2::perf::tickEnd (std::uint64_t tickWallNs) noexcept
 Tick boundary marker — call once per server tick() end.
void group2::perf::initFromEnv ()
 Initialize from environment variables.
void group2::perf::startAggregator (std::function< void(const Snapshot &)> cb)
 Spawn the 1 Hz aggregator thread.
void group2::perf::stopAggregator ()
 Stop the aggregator and join its thread. Idempotent.

Variables

std::atomic< bool > group2::perf::enabled {false}
 Master switch.

Detailed Description

Profiler runtime: scope registration, sample recording, 1 Hz aggregator thread.