Gondwana Game Engine Development (master) - 2.7.0
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
TelemetrySummary.cs
2
15
31
39public sealed record TelemetrySummary(
40 TelemetryAvailability Availability,
41 long Count,
42 double Sum,
43 double? Minimum,
44 double? Maximum,
45 double? Last)
46{
48 public TelemetryMetricKind Kind { get; init; }
49
51 public double? WindowDelta { get; init; }
52
54 public double? LastObservedSeconds { get; init; }
55
57 public double? Mean => Count == 0 ? null : Sum / Count;
58
62 public static TelemetrySummary Combine(IEnumerable<TelemetrySummary> summaries)
63 {
64 ArgumentNullException.ThrowIfNull(summaries);
65 long count = 0;
66 double sum = 0;
67 double? min = null, max = null, last = null;
68 double? observed = null, delta = null;
69 TelemetryMetricKind? kind = null;
70 var availability = TelemetryAvailability.Unsupported;
71
72 foreach (var value in summaries)
73 {
74 if (kind is not null && kind != value.Kind)
75 throw new ArgumentException("Cannot combine different metric kinds.", nameof(summaries));
76
77 kind = value.Kind;
78
79 if (value.Availability > availability)
80 availability = value.Availability;
81
82 if (value.Count == 0)
83 continue;
84
85 count += value.Count;
86 sum += value.Sum;
87 min = min is null ? value.Minimum : Math.Min(min.Value, value.Minimum!.Value);
88 max = max is null ? value.Maximum : Math.Max(max.Value, value.Maximum!.Value);
89 last = value.Last;
90 observed = value.LastObservedSeconds;
91
92 if (value.WindowDelta is { } change)
93 delta = (delta ?? 0) + change;
94 }
95
96 return new(
97 availability,
98 count,
99 sum,
100 min,
101 max,
102 last)
103 {
104 Kind = kind ?? TelemetryMetricKind.Sample,
105 LastObservedSeconds = observed,
106 WindowDelta = delta
107 };
108 }
109}
110
119public sealed record TelemetryOptions
120{
122 internal const long MaxRetainedMetricSummaries = 1_048_576;
123
125 internal const long MaxPublishedMetricSummariesPerSecond = 262_144;
126
128 public TimeSpan Interval { get; init; } = TimeSpan.FromMilliseconds(250);
129
131 public int HistoryCapacity { get; init; } = 120;
132
134 public int SourceCapacity { get; init; } = 16;
135
137 public int MetricCapacity { get; init; } = 128;
138
140 internal void Validate()
141 {
142 if (Interval < TimeSpan.FromMilliseconds(10) || Interval > TimeSpan.FromMinutes(1))
143 throw new ArgumentOutOfRangeException(nameof(Interval));
144
145 if (HistoryCapacity is < 1 or > 1024)
146 throw new ArgumentOutOfRangeException(nameof(HistoryCapacity));
147
148 if (SourceCapacity is < 1 or > 64)
149 throw new ArgumentOutOfRangeException(nameof(SourceCapacity));
150
151 if (MetricCapacity is < 8 or > 512)
152 throw new ArgumentOutOfRangeException(nameof(MetricCapacity));
153
154 long retainedMetricSummaries =
155 (long)HistoryCapacity * SourceCapacity * MetricCapacity;
156
157 if (retainedMetricSummaries > MaxRetainedMetricSummaries)
158 {
159 throw new ArgumentException(
160 $"HistoryCapacity * SourceCapacity * MetricCapacity must not exceed {MaxRetainedMetricSummaries:N0} retained metric summaries.");
161 }
162
163 double publishedMetricSummariesPerSecond =
164 (double)SourceCapacity * MetricCapacity / Interval.TotalSeconds;
165
166 if (publishedMetricSummariesPerSecond > MaxPublishedMetricSummariesPerSecond)
167 {
168 throw new ArgumentException(
169 $"SourceCapacity * MetricCapacity / Interval.TotalSeconds must not exceed {MaxPublishedMetricSummariesPerSecond:N0} configured metric summaries per second.");
170 }
171 }
172}
173
180public sealed record TelemetrySnapshot(
181 long Generation,
182 double StartedSeconds,
183 double EndedSeconds,
184 IReadOnlyList<TelemetrySourceSnapshot> Sources,
185 bool Truncated)
186{
188 public double ElapsedSeconds => EndedSeconds - StartedSeconds;
189}
190
196public sealed record TelemetrySourceSnapshot(
197 long Id,
198 string Name,
199 string Backend,
200 IReadOnlyDictionary<string, TelemetrySummary> Metrics);
record TelemetrySummary(TelemetryAvailability Availability, long Count, double Sum, double? Minimum, double? Maximum, double? Last)
Detached statistics for observations in one window; durations use milliseconds.
record TelemetrySourceSnapshot(long Id, string Name, string Backend, IReadOnlyDictionary< string, TelemetrySummary > Metrics)
Detached source identity, backend label, and measurements. No runtime objects are retained.
TelemetryAvailability
Whether an observation is meaningful for its source and window.
@ NotYetSampled
The measurement is supported but has no samples in this window.
@ NotApplicable
The measurement does not apply to this rendering path.
@ Available
At least one observation is present.
@ Unsupported
The source does not implement this measurement.
TelemetryMetricKind
How observations should be interpreted when combining windows.
@ Gauge
Observed state; use Last for current state, not the sum across windows.
@ Sample
Independent work samples; count divided by elapsed seconds gives cadence.
@ LifetimeCounter
Renderer-owned cumulative value; WindowDelta is relative to the previous observation.
record TelemetryOptions
Validated shared settings; configure only when collection is inactive.
record TelemetrySnapshot(long Generation, double StartedSeconds, double EndedSeconds, IReadOnlyList< TelemetrySourceSnapshot > Sources, bool Truncated)
Detached completed window. Sources can be observed asynchronously within its interval.