tess 0.4.0
Performance-first tile and path simulation substrate
Loading...
Searching...
No Matches
export.h
1#pragma once
2
3#include <tess/diagnostics/diagnostics.h>
4#include <tess/diagnostics/trace.h>
5
6#include <array>
7#include <cstddef>
8
9namespace tess::diagnostics {
10
11#if TESS_DIAGNOSTICS_ENABLED
12
20 std::array<TraceCategoryStats, trace_category_count> per_category{};
21
22 // Timing accumulator for a category, guarding the Count sentinel and any
23 // out-of-range value.
24 [[nodiscard]] auto category(TraceCategory value) const noexcept
25 -> const TraceCategoryStats& {
26 static constexpr TraceCategoryStats kZero{};
27 const auto index = static_cast<std::size_t>(value);
28 if (index >= per_category.size()) {
29 return kZero;
30 }
31 return per_category[index];
32 }
33};
34
41 PathCounters path;
42 AllocationCounters allocation;
44 TimingSnapshot timing;
45};
46
53[[nodiscard]] inline auto capture_timing(const TraceBuffer& buffer) noexcept
55 TimingSnapshot snapshot;
56 snapshot.per_category = buffer.category_stats();
57 return snapshot;
58}
59
66[[nodiscard]] inline auto capture_diagnostics(
67 const PathCounters& path, const AllocationCounters& allocation,
68 const QueuedPhaseCounters& queued, const TraceBuffer& buffer) noexcept
69 -> DiagnosticsSnapshot {
70 return DiagnosticsSnapshot{path, allocation, queued, capture_timing(buffer)};
71}
72
73#endif // TESS_DIAGNOSTICS_ENABLED
74
75} // namespace tess::diagnostics
Definition trace.h:90
Definition diagnostics.h:82
Definition diagnostics.h:57
Definition diagnostics.h:92
Definition export.h:19