From 230d465a355623bbb66b7169e86369a8f42b6659 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Wed, 21 Oct 2026 11:08:21 +0000 Subject: [PATCH] Bound the dilogarithm declines by what they allocate rather than a wall clock ADilogarithmIsDeclinedAtOnce was the suite's one wall-clock bound, 20 s, and it measured the runner: on a loaded machine x^2 sech(x)^2 took 24 to 58 s on four branches, and on three of them and on master it allocates 0.999 GB. The four integrands allocate 0.03, 0.04, 0.11 and 1.0 GB cold; the bound is 3 GB on the test's own thread, as RewriteAllocationTest bounds its fast paths. At 0.3 GB the sech row fails, so the measurement counts the integrator's work. Part of #233. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --- .../Calculus/ExponentialSubstitutionIntegralTest.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/Tests/UnitTests/Calculus/ExponentialSubstitutionIntegralTest.cs b/Sources/Tests/UnitTests/Calculus/ExponentialSubstitutionIntegralTest.cs index 7bee8667a..3ac3e3487 100644 --- a/Sources/Tests/UnitTests/Calculus/ExponentialSubstitutionIntegralTest.cs +++ b/Sources/Tests/UnitTests/Calculus/ExponentialSubstitutionIntegralTest.cs @@ -227,10 +227,15 @@ public void AnInverseFunctionOfAHyperbolicOneTimesARationalFunctionOfThem() [InlineData("x^2*sech(x)^2")] public void ADilogarithmIsDeclinedAtOnce(string integrand) { - var watch = System.Diagnostics.Stopwatch.StartNew(); + // Bounded by what the decline allocates, not by a wall clock, which measures the runner: + // on a loaded machine `x^2 sech(x)^2` took 26-58 s against a 20 s bound with its + // allocation unchanged. Measured cold, the four allocate 0.03, 0.04, 0.11 and 1.0 GB; + // the search this guards against ran for twenty-five seconds. + var before = GC.GetAllocatedBytesForCurrentThread(); var integral = integrand.ToEntity().Integrate("x"); + var allocated = GC.GetAllocatedBytesForCurrentThread() - before; Assert.Contains("integral(", integral.Stringize()); - Assert.True(watch.ElapsedMilliseconds < 20_000, $"{integrand} took {watch.ElapsedMilliseconds} ms to decline"); + Assert.True(allocated < 3_000_000_000L, $"{integrand} allocated {allocated / 1e9:F2} GB to decline"); } ///