Gondwana Game Engine Development (master) - 2.6.1
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
RuntimeTelemetryExample.cs
1using System.Drawing;
6
8
10public static class RuntimeTelemetryExample
11{
14 public static IDisposable StartCollection() => Engine.Instance.Profiler.Start();
15
20 public static ProfilerWidget CreateWidget(RenderSurfaceHostBase host, View view)
21 {
22 var widget = new ProfilerWidget(
23 host,
24 view,
25 new Rectangle(12, 12, 700, 520));
26
27 // Hide any metric globally, or target a single named source.
28 widget.SetMeasurementVisible("layers.omitted", false);
29 widget.SetMeasurementVisible("Render surface", "snapshot.commands.approximate", false);
30 widget.ContextInfo = ProfilerContextInfo.View | ProfilerContextInfo.Backbuffer;
31 widget.AdditionalLinesProvider = _ => ["Diagnostics: application-defined line"];
32 return widget;
33 }
34
38 public static void PrintLatest(RuntimeProfiler profiler, TextWriter output)
39 {
40 var snapshot = profiler.GetLatestSnapshot();
41 if (snapshot is null) return;
42 foreach (var source in snapshot.Sources)
43 {
44 if (source.Metrics.TryGetValue("cycle.cpu.ms", out var cycle) &&
45 cycle.Availability == TelemetryAvailability.Available)
46 output.WriteLine($"CPS={cycle.Count / snapshot.ElapsedSeconds:F1}; CPU mean={cycle.Mean:F3} ms");
47 }
48 }
49}
Opt-in, bounded runtime measurements independent of legacy CPS notifications.
TelemetrySnapshot? GetLatestSnapshot()
Returns the latest completed bucket, or null before one completes.
IDisposable Start()
Starts or joins collection. Disposing the last request stops collection.
Represents the core game engine singleton responsible for managing the main update loop,...
Definition Engine.cs:36
static Engine Instance
Gets the singleton instance of the Engine.
Definition Engine.cs:49
Diagnostics.RuntimeProfiler Profiler
Opt-in runtime CPU measurements and bounded history, independent of CPS notifications.
Definition Engine.cs:228
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
Represents a rendered view of a scene, combining a camera position with a viewport configuration to c...
Definition View.cs:14
Displays detached RuntimeProfiler snapshots as a screen-space HUD widget.
TelemetryAvailability
Whether an observation is meaningful for its source and window.
ProfilerContextInfo
Selects optional non-profiler runtime context rendered alongside telemetry measurements.
@ View
Displays camera position, viewport zoom, and viewport dimensions.