Skip to content

Commit d3a6bce

Browse files
Bound the dilogarithm declines by what they allocate rather than a wall clock (#2011)
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. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent b14655a commit d3a6bce

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎Sources/Tests/UnitTests/Calculus/ExponentialSubstitutionIntegralTest.cs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,15 @@ public void AnInverseFunctionOfAHyperbolicOneTimesARationalFunctionOfThem()
227227
[InlineData("x^2*sech(x)^2")]
228228
public void ADilogarithmIsDeclinedAtOnce(string integrand)
229229
{
230-
var watch = System.Diagnostics.Stopwatch.StartNew();
230+
// Bounded by what the decline allocates, not by a wall clock, which measures the runner:
231+
// on a loaded machine `x^2 sech(x)^2` took 26-58 s against a 20 s bound with its
232+
// allocation unchanged. Measured cold, the four allocate 0.03, 0.04, 0.11 and 1.0 GB;
233+
// the search this guards against ran for twenty-five seconds.
234+
var before = GC.GetAllocatedBytesForCurrentThread();
231235
var integral = integrand.ToEntity().Integrate("x");
236+
var allocated = GC.GetAllocatedBytesForCurrentThread() - before;
232237
Assert.Contains("integral(", integral.Stringize());
233-
Assert.True(watch.ElapsedMilliseconds < 20_000, $"{integrand} took {watch.ElapsedMilliseconds} ms to decline");
238+
Assert.True(allocated < 3_000_000_000L, $"{integrand} allocated {allocated / 1e9:F2} GB to decline");
234239
}
235240

236241
/// <summary>

0 commit comments

Comments
 (0)