독립 검증 도구 추가와 앱 상태 책임 분리

This commit is contained in:
2026-09-06 18:09:11 +09:00
parent 0f0431de5a
commit 002a922e1b
62 changed files with 3454 additions and 2008 deletions
@@ -0,0 +1,42 @@
using System.Runtime.InteropServices;
namespace ProjectQuint.Probes;
public sealed record CoreBenchmarkReport(int SchemaVersion, bool Complete, DateTimeOffset MeasuredAtUtc,
string Runtime, string OperatingSystem, string Architecture, int ProcessorCount,
int Notes, int Events, uint Seed, int FrameRate, int WarmupIterations, int RequestedIterations,
ReplayObservation[] Samples);
public static class CoreBenchmark
{
public static CoreBenchmarkReport Run(int notes, uint seed, int frameRate, int iterations,
Action<CoreBenchmarkReport> checkpoint)
{
if (iterations < 1 || iterations > 100)
throw new ArgumentOutOfRangeException(nameof(iterations), "Use 1 to 100 iterations.");
var workload = SyntheticWorkload.Create(notes, seed);
const int warmups = 3;
JudgementSnapshot expected = default;
for (var index = 0; index < warmups; index++)
expected = ReplayRunner.Run(workload, frameRate).Judgement;
var samples = new List<ReplayObservation>(iterations);
var measuredAt = DateTimeOffset.UtcNow;
for (var index = 0; index < iterations; index++)
{
var sample = ReplayRunner.Run(workload, frameRate);
if (sample.Judgement != expected || !sample.Judgement.Finished)
throw new InvalidOperationException("The benchmark replay diverged from its warmup result.");
samples.Add(sample);
checkpoint(Report(false));
}
return Report(true);
CoreBenchmarkReport Report(bool complete) => new(1, complete, measuredAt,
RuntimeInformation.FrameworkDescription,
System.OperatingSystem.IsMacOS() ? "macOS" :
System.OperatingSystem.IsLinux() ? "Linux" :
System.OperatingSystem.IsWindows() ? "Windows" : "Other",
RuntimeInformation.ProcessArchitecture.ToString(), Environment.ProcessorCount,
notes, workload.Events.Length, seed, frameRate, warmups, iterations, samples.ToArray());
}
}