Files
poli0981andClaude Opus 5.5 ff949afc6f feat(legal): NOTICE with the GPLv3 section 7 additional terms, the licence header in every source file, and the documents for people who build, contribute or redistribute (D45, beta.12 PR-1) (#253)
- NOTICE: copyright, GPL-3.0-only, and three additional terms of the kinds section 7 permits - (b) preserve the
  notices and the attribution in the program's legal notices, (c) mark a modified version as different and do not
  call it "FrameLedger" alone, (e) no trademark rights in the name. Shipped as licenses\NOTICE.txt; release.yml
  refuses a published tree without it.
- Section 7 wants additional terms named in the source files: every first-party .cs .cpp .h .inl .ps1 .xaml file
  (1,053; src/native/third_party excluded) opens with the SPDX line and a pointer to NOTICE. tools/notice-check.ps1
  is the gate (six self-test cases, both directions; -Fix writes a missing header) and tools/resx-gen.ps1 generates
  the string accessors with the header.
- The native VERSIONINFO LegalCopyright said GPL-3.0-or-later; it now names the real licence.
- CONTRIBUTING.md, FORKING.md, CODE_OF_CONDUCT.md (Contributor Covenant 2.1 by reference), legal/TRADEMARKS.md.
- 12_BUILD gate list, CLAUDE.md layout and conventions.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 22:16:00 +07:00

84 lines
3.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FluentAssertions;
using FrameLedger.Domain.Metrics;
namespace FrameLedger.Domain.Tests.Metrics;
/// <summary>
/// <c>03_METRICS</c> §Core definitions as goldens: the lows are <c>1000 / p</c> by linear interpolation, the
/// sufficiency guards sit at exactly 1,000 and 10,000, and an empty series is N/A everywhere.
/// </summary>
public sealed class FrameStatisticsTests
{
private static List<double> Ramp(int n) => [.. Enumerable.Range(1, n).Select(i => (double)i)];
[Fact]
public void MedianMinMaxAndSigmaOverASmallSeries()
{
FrameStatistics s = FrameStatistics.From([10, 20, 30, 40], presented: false);
s.Count.Should().Be(4);
s.Presented.Should().BeFalse();
s.MedianFps.Should().Be(1000.0 / 25);
s.MinFps.Should().Be(1000.0 / 40, "min FPS is the SLOWEST frame");
s.MaxFps.Should().Be(1000.0 / 10, "max FPS is the fastest frame");
s.MeanMs.Should().Be(25);
s.StdDevMs.Should().BeApproximately(Math.Sqrt(125), 1e-9, "population σ, not sample σ");
s.P1LowFps.Should().BeNull("4 frames is under the 1,000 the 1% Low needs");
s.P01LowFps.Should().BeNull();
}
[Fact]
public void TheOnePercentLowNeedsExactlyOneThousandFrames()
{
FrameStatistics.From(Ramp(999), presented: false).P1LowFps.Should().BeNull();
FrameStatistics at = FrameStatistics.From(Ramp(1000), presented: false);
at.P1LowFps.Should().Be(1000.0 / (1 + (0.99 * 999)), "rank 0.99 × 999 = 989.01, interpolated");
at.P01LowFps.Should().BeNull();
}
[Fact]
public void ThePointOnePercentLowNeedsExactlyTenThousandFrames()
{
FrameStatistics.From(Ramp(9_999), presented: false).P01LowFps.Should().BeNull();
FrameStatistics at = FrameStatistics.From(Ramp(10_000), presented: false);
at.P01LowFps.Should().Be(1000.0 / (1 + (0.999 * 9_999)));
at.P1LowFps.Should().NotBeNull();
}
[Fact]
public void ThePresentedLabelIsCarriedNotDecided()
{
// When frame generation is not measured the lows are over presents and the report prints
// "(presented)"; the statistics carry the flag and never infer it.
FrameStatistics.From([10, 10], presented: true).Presented.Should().BeTrue();
FrameStatistics.Empty(presented: true).Presented.Should().BeTrue();
}
[Fact]
public void AnEmptySeriesIsNotApplicableEverywhereAndNeverZero()
{
FrameStatistics s = FrameStatistics.From([], presented: false);
s.Count.Should().Be(0);
s.MedianFps.Should().BeNull();
s.MinFps.Should().BeNull();
s.MaxFps.Should().BeNull();
s.MeanMs.Should().BeNull();
s.StdDevMs.Should().BeNull();
}
[Fact]
public void AZeroFrameTimeIsNotARate()
{
FrameStatistics s = FrameStatistics.From([0, 10], presented: false);
s.MaxFps.Should().BeNull("1000 / 0 is not a frame rate");
s.MinFps.Should().Be(100);
}
}