From 39066900773e7857faf2d02e7ed51b71d219d97d Mon Sep 17 00:00:00 2001 From: godosa Date: Tue, 6 Oct 2026 23:39:36 +0200 Subject: godosa-engine: initial public history --- src/Godosa.Core/Diagnostics/PerfCsv.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Godosa.Core/Diagnostics/PerfCsv.cs (limited to 'src/Godosa.Core/Diagnostics/PerfCsv.cs') diff --git a/src/Godosa.Core/Diagnostics/PerfCsv.cs b/src/Godosa.Core/Diagnostics/PerfCsv.cs new file mode 100644 index 0000000..6c4ef0d --- /dev/null +++ b/src/Godosa.Core/Diagnostics/PerfCsv.cs @@ -0,0 +1,27 @@ +using System.Globalization; + +namespace Godosa.Core.Diagnostics; + +/// Per-frame CSV rows for perf-log stall hunts. Fixed columns first, then the +/// caller's own ( names, values, same order). +/// Invariant culture; times in ms with 3 decimals; blank = unknown (e.g. GPU before a +/// timer query reports). +public static class PerfCsv +{ + public const string BaseHeader = "t_s,frame_ms,work_ms,sim_ticks,sim_ms,gpu_ms"; + + public static string Header(params string[] extraColumns) => + extraColumns.Length == 0 ? BaseHeader : BaseHeader + "," + string.Join(',', extraColumns); + + public static string Row(double timeSeconds, double frameSeconds, double workSeconds, int simTicks, + double simSeconds, double? gpuSeconds, params string[] extraValues) + { + string row = string.Create(CultureInfo.InvariantCulture, + $"{timeSeconds:F3},{frameSeconds * 1000:F3},{workSeconds * 1000:F3},{simTicks},{simSeconds * 1000:F3},{Ms(gpuSeconds)}"); + return extraValues.Length == 0 ? row : row + "," + string.Join(',', extraValues); + } + + /// Seconds → ms with 3 decimals (invariant); blank for null. + public static string Ms(double? seconds) => + seconds is { } s ? (s * 1000).ToString("F3", CultureInfo.InvariantCulture) : ""; +} -- cgit