tess
0.4.0
Performance-first tile and path simulation substrate
Toggle main menu visibility
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
9
namespace
tess::diagnostics {
10
11
#if TESS_DIAGNOSTICS_ENABLED
12
19
struct
TimingSnapshot
{
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
40
struct
DiagnosticsSnapshot
{
41
PathCounters
path;
42
AllocationCounters
allocation;
43
QueuedPhaseCounters
queued;
44
TimingSnapshot
timing;
45
};
46
53
[[nodiscard]]
inline
auto
capture_timing(
const
TraceBuffer
& buffer)
noexcept
54
->
TimingSnapshot
{
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
tess::diagnostics::TraceBuffer
Definition
trace.h:90
tess::diagnostics::AllocationCounters
Definition
diagnostics.h:82
tess::diagnostics::DiagnosticsSnapshot
Definition
export.h:40
tess::diagnostics::PathCounters
Definition
diagnostics.h:57
tess::diagnostics::QueuedPhaseCounters
Definition
diagnostics.h:92
tess::diagnostics::TimingSnapshot
Definition
export.h:19
tess::diagnostics::TraceCategoryStats
Definition
trace.h:74
include
tess
diagnostics
export.h
Generated by
1.17.0