4#include <aegis2d/core/export.hpp>
47 std::span<const TraceEvent>
events{};
95 using Clock = std::chrono::steady_clock;
123 void begin(
std::string_view name);
134 [[nodiscard]]
double last_frame_ms() const noexcept;
141 void start_trace(
std::
size_t capacity = 1'000'000);
144 void stop_trace() noexcept;
148 [[nodiscard]]
bool tracing() const noexcept;
156 [[nodiscard]]
std::
size_t dropped() const noexcept;
159 void record(
std::string_view name,
Clock::time_point start,
Clock::time_point end);
162 std::size_t entry = 0;
163 Clock::time_point start;
166 std::vector<ProfileEntry> frame_;
168 std::vector<std::size_t> parents_;
169 std::vector<Open> open_;
170 std::vector<ProfileEntry> last_;
171 std::vector<TraceEvent> trace_;
172 std::size_t trace_capacity_ = 0;
173 std::size_t dropped_ = 0;
174 bool tracing_ =
false;
175 Clock::time_point frame_start_;
176 double last_ms_ = 0.0;
177 bool in_frame_ =
false;
178 bool enabled_ =
true;
189 std::string_view process =
"aegis2d");
197 std::span<const TraceThread> threads,
198 std::string_view process =
"aegis2d");
206 std::size_t most = 12);
Times a scope while it lives: from Profiler::scope() to its destruction.
Definition profiler.hpp:53
ProfileScope(const ProfileScope &)=delete
~ProfileScope()
Ends the scope.
ProfileScope & operator=(const ProfileScope &)=delete
ProfileScope & operator=(ProfileScope &&)=delete
ProfileScope(ProfileScope &&)=delete
Timers around the parts of a frame (its phases, each system of a ecs::Scheduler......
Definition profiler.hpp:92
bool enabled() const noexcept
Tells whether the timers are on.
Profiler()=default
Profiler on, with no frame yet.
std::chrono::steady_clock Clock
Clock of the timers.
Definition profiler.hpp:95
void set_enabled(bool enabled) noexcept
Turns the timers on or off.
Logging, time, main loop, events and configuration shared by client and server.
Definition clock.hpp:11
std::vector< std::string > profile_lines(const Profiler &profiler, std::size_t most=12)
The breakdown of the last frame as lines of the metrics overlay.
void save_chrome_trace(const std::filesystem::path &file, std::span< const TraceThread > threads, std::string_view process="aegis2d")
Writes traces to a file in the Chrome trace format (write_chrome_trace()).
void write_chrome_trace(std::ostream &out, std::span< const TraceThread > threads, std::string_view process="aegis2d")
Writes traces in the Chrome trace format, which Perfetto (ui.perfetto.dev) and chrome://tracing open.
Definition endpoint.hpp:85
Time a named part of a frame took, as Profiler::last_frame() gives it.
Definition profiler.hpp:19
double ms
Time spent in it during the frame, every call added, in milliseconds.
Definition profiler.hpp:25
std::size_t depth
How deep it is: 0 for a phase of the frame, 1 for a scope inside one...
Definition profiler.hpp:23
std::uint32_t calls
How many times it was entered during the frame (the fixed steps of a frame run the same systems sever...
Definition profiler.hpp:28
std::string name
Name of the scope, such as "update" or a system's name.
Definition profiler.hpp:21
A scope timed while tracing (Profiler::start_trace()), for write_chrome_trace().
Definition profiler.hpp:32
std::string name
Name of the scope, or "frame" for a whole frame.
Definition profiler.hpp:34
double start_us
When it started, in microseconds of the profiler's clock (the same for every profiler of the process,...
Definition profiler.hpp:37
double duration_us
How long it took, in microseconds.
Definition profiler.hpp:39
The trace of one thread, as write_chrome_trace() writes it.
Definition profiler.hpp:43
std::span< const TraceEvent > events
Its events, from Profiler::trace().
Definition profiler.hpp:47
std::string name
Name of the thread in the viewer, such as "main" or "room 2".
Definition profiler.hpp:45