test: stretch timed budgets on the shared CI runner
CI / Build and test (pull_request) Successful in 8m3s
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 14s
CI / PostgreSQL 16 integration (pull_request) Successful in 5m56s
CI / PostgreSQL 17 integration (pull_request) Successful in 6m5s
CI / Docker image (pull_request) Successful in 1m18s

The owner's runner shares its CPU and disks with Gitea and the server's other
containers, so the 100k-frame bulk insert took 10-19 s against 15 s from one
run to the next. CHRONOS_TEST_TIME_FACTOR (default 1) stretches the timed
tests' budgets; CI and release set 3, the weekly performance gates keep them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-23 12:19:36 +02:00
1 parent f4800fd86d
commit 8566072c9a
12 files changed
+55 -8

No files matched your search

@@ -80,7 +80,7 @@ public sealed class VisualsSmokeTests
list.UpdateLayout();
}
stopwatch.Stop();
Assert.Less(stopwatch.Elapsed.TotalSeconds, 5, "300 scroll steps");
Assert.Less(stopwatch.Elapsed.TotalSeconds, TestTiming.Budget(5), "300 scroll steps");
Assert.LessOrEqual(panel.Children.Count, rows * columns);
panel.SetVerticalOffset(panel.ExtentHeight / 2);
@@ -184,7 +184,7 @@ public sealed class LightAnalyzerTests(TestContext context)
context.Log(string.Create(CultureInfo.InvariantCulture, $"10,000 frames analysed in {watch.Elapsed.TotalMilliseconds:F1} ms"));
Assert.Equal(10_000, report.DayPhases.Length);
Assert.Count(1, report.ExposureSteps);
Assert.Less(watch.Elapsed.TotalSeconds, 2);
Assert.Less(watch.Elapsed.TotalSeconds, TestTiming.Budget(2));
}
[Test]
@@ -42,7 +42,7 @@ public sealed class JpegPerformanceTests(TestContext context)
$"decode all cores {parallel.TotalMilliseconds:F0} ms");
Console.WriteLine($"[perf] {context.LogText.Trim()}");
Assert.Equal(W, image!.Width);
Assert.Less(single.TotalSeconds, 3.0);
Assert.Less(single.TotalSeconds, TestTiming.Budget(3.0));
}
/// <summary>Photo-like content: smooth illumination, texture and mild noise (≈ q90 file size of a real photo).</summary>
@@ -151,6 +151,6 @@ public sealed class ResamplerTests(TestContext context)
using var lanczos = Resampler.Resize(source, 1920, 1280);
context.Log($"24 MP → 320 px box {box.TotalMilliseconds:F0} ms; → 1920 px Lanczos3 {sw.Elapsed.TotalMilliseconds:F0} ms");
Assert.Equal(320, thumb.Width);
Assert.Less(box.TotalSeconds, 2.5);
Assert.Less(box.TotalSeconds, TestTiming.Budget(2.5));
}
}
@@ -125,7 +125,7 @@ public sealed class RobustnessTests(TestContext context)
}
watch.Stop();
context.Log($"2000 JPEG headers in {watch.ElapsedMilliseconds} ms");
Assert.Less(watch.Elapsed.TotalSeconds, 2.0);
Assert.Less(watch.Elapsed.TotalSeconds, TestTiming.Budget(2.0));
}
[Test]
@@ -29,8 +29,8 @@ public sealed class RawPerformanceTests(TestContext context)
Assert.Equal(W / 2, halfSize.Width);
context.Log($"24 MP DNG: AHD full size {ahd.TotalMilliseconds:F0} ms, binned half size {half.TotalMilliseconds:F0} ms ({Environment.ProcessorCount} cores)");
Console.WriteLine($"[perf] {context.LogText.Trim()}");
Assert.Less(ahd.TotalSeconds, 4.0);
Assert.Less(half.TotalSeconds, 1.0);
Assert.Less(ahd.TotalSeconds, TestTiming.Budget(4.0));
Assert.Less(half.TotalSeconds, TestTiming.Budget(1.0));
}
/// <summary>Best of two runs (the machine is shared; the first run also pays JIT warm-up).</summary>
@@ -22,7 +22,7 @@ public abstract class BulkInsertTests(TestContext context) : RepositoryTest(cont
Assert.Equal(100_000L, await db.Frames.BulkInsertAsync(frames, Ct));
watch.Stop();
Context.Log($"{Dialect}: 100k frames in {watch.Elapsed.TotalSeconds:F2} s");
Assert.Less(watch.Elapsed.TotalSeconds, 15.0, "bulk insert time");
Assert.Less(watch.Elapsed.TotalSeconds, TestTiming.Budget(15.0), "bulk insert time");
var refreshed = await db.Sequences.RefreshStatsAsync(sequence.Id, Ct);
Assert.Equal(100_000, refreshed!.FrameCount);
+23
View File
@@ -0,0 +1,23 @@
using System.Globalization;
namespace Chronos.Testing;
/// <summary>
/// Time budgets of timed tests. <c>CHRONOS_TEST_TIME_FACTOR</c> (at least 1, default 1) stretches them on a CI runner
/// that shares its CPU and disks with other services (the Gitea runner on the owner's server, amended 2026-10-23, R3);
/// on a development PC the budgets apply as written, and the performance gates of <c>perf.yml</c> never set it.
/// </summary>
public static class TestTiming
{
public const string Variable = "CHRONOS_TEST_TIME_FACTOR";
/// <summary>The factor from <see cref="Variable"/>; 1 when unset, unreadable or below 1.</summary>
public static double Factor { get; } = Parse(Environment.GetEnvironmentVariable(Variable));
/// <summary><paramref name="seconds"/> stretched by <see cref="Factor"/>.</summary>
public static double Budget(double seconds) => seconds * Factor;
/// <summary>The factor a value of <see cref="Variable"/> gives.</summary>
public static double Parse(string? value) =>
double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var factor) && factor >= 1 && double.IsFinite(factor) ? factor : 1;
}
@@ -0,0 +1,18 @@
using Chronos.Testing;
namespace Chronos.Tools.Tests;
/// <summary>Time budgets stretch only by an explicit factor of at least 1 (BRIEF §20.1, amended 2026-10-23, R3).</summary>
public sealed class TestTimingTests
{
[Theory]
[Case("3", 3.0)]
[Case("1.5", 1.5)]
[Case(null, 1.0)]
[Case("", 1.0)]
[Case("0.5", 1.0)]
[Case("fast", 1.0)]
[Case("Infinity", 1.0)]
public void TheFactorIsReadInvariantlyAndNeverShrinksABudget(string? value, double expected) =>
Assert.Equal(expected, TestTiming.Parse(value));
}