diff options
| author | godosa <godosa@godosa.eu> | 2026-10-06 23:39:36 +0200 |
|---|---|---|
| committer | godosa <godosa@godosa.eu> | 2026-10-06 23:39:36 +0200 |
| commit | 39066900773e7857faf2d02e7ed51b71d219d97d (patch) | |
| tree | ffab8e4ddd971626776c3b1f4ce1da2c186c2187 /src/Godosa.Core.Tests/Diagnostics/GpuAndCsvTests.cs | |
| download | godosa-engine-39066900773e7857faf2d02e7ed51b71d219d97d.tar.gz godosa-engine-39066900773e7857faf2d02e7ed51b71d219d97d.zip | |
godosa-engine: initial public history
Diffstat (limited to 'src/Godosa.Core.Tests/Diagnostics/GpuAndCsvTests.cs')
| -rw-r--r-- | src/Godosa.Core.Tests/Diagnostics/GpuAndCsvTests.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/Godosa.Core.Tests/Diagnostics/GpuAndCsvTests.cs b/src/Godosa.Core.Tests/Diagnostics/GpuAndCsvTests.cs new file mode 100644 index 0000000..46cf5ed --- /dev/null +++ b/src/Godosa.Core.Tests/Diagnostics/GpuAndCsvTests.cs @@ -0,0 +1,53 @@ +using System.Globalization; +using System.Threading; +using Godosa.Core.Diagnostics; +using Xunit; + +namespace Godosa.Core.Tests.Diagnostics; + +public class GpuAndCsvTests +{ + [Fact] + public void GpuSamples_AverageSeparatelyFromFrames() + { + var stats = new FrameTimeStats(capacity: 4); + stats.Record(0.016, 0.002, 1, 0.0001); + Assert.Equal(0, stats.Summarize().GpuSamples); + Assert.Equal(0.0, stats.Summarize().AvgGpuMs); + + stats.RecordGpu(0.001); + stats.RecordGpu(0.003); + + var s = stats.Summarize(); + Assert.Equal(2, s.GpuSamples); + Assert.Equal(2.0, s.AvgGpuMs, precision: 9); + } + + [Fact] + public void GpuSamples_RollOverTheWindow() + { + var stats = new FrameTimeStats(capacity: 2); + stats.RecordGpu(0.010); + stats.RecordGpu(0.001); + stats.RecordGpu(0.003); + + Assert.Equal(2.0, stats.Summarize().AvgGpuMs, precision: 9); + } + + [Fact] + public void CsvRow_IsInvariantCulture_MsWithThreeDecimals_GpuBlankWhenUnknown() + { + var previous = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE"); // comma decimals must not leak in + try + { + Assert.Equal("t_s,frame_ms,work_ms,sim_ticks,sim_ms,gpu_ms", PerfCsv.Header()); + Assert.Equal("12.500,16.667,2.000,1,0.100,1.250", PerfCsv.Row(12.5, 0.0166667, 0.002, 1, 0.0001, 0.00125)); + Assert.Equal("0.000,16.667,2.000,0,0.000,", PerfCsv.Row(0, 0.0166667, 0.002, 0, 0, null)); + } + finally + { + Thread.CurrentThread.CurrentCulture = previous; + } + } +} |
