Skip to content

Commit 253f1ee

Browse files
committed
Query every benchmark point once instead of nine times
benchmarkPoint strides by 73 and 151 modulo 1152, and both strides are coprime to 1152, so the sequence has period 1152: an index past that repeats a point already queried. Iterating to 9999 asked the same 1152 questions nearly nine times over. That bought no coverage and cost enough interpreted work to reach the twenty second test budget, so the test failed as a timeout on a loaded machine while saying nothing about the polygon. One full period queries every point the helper can produce, and both aggregate assertions compare totals which scale with the iteration count, so they hold unchanged.
1 parent 98b1140 commit 253f1ee

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

wurst/math/PolygonTests.wurst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,17 @@ function benchmarkPoint(int index) returns vec2
179179
(polygon.classify(vec2(96, 96)) == polygon.classifyLinear(vec2(96, 96))).assertTrue()
180180
destroy polygon
181181

182-
@Test function acceleratedClassificationMatchesLinearFor10000Points()
182+
/** Every point benchmarkPoint can produce, which is fewer than it looks.
183+
Both strides are coprime to 1152, so the sequence has period 1152 and an index past that
184+
repeats a point already queried. Ten thousand iterations asked the same 1152 questions
185+
nearly nine times over, for no coverage and enough interpreted work to reach the
186+
twenty second test budget on a loaded machine. */
187+
@Test function acceleratedClassificationMatchesLinearForEveryBenchmarkPoint()
183188
let polygon = benchmarkPolygon()
184189
var totalCandidates = 0
185190
var linearEdges = 0
186191
var mixedQueries = 0
187-
for i = 0 to 9999
192+
for i = 0 to 1151
188193
let point = benchmarkPoint(i)
189194
(polygon.classify(point) == polygon.classifyLinear(point)).assertTrue()
190195
if point.x >= 0 and point.x <= 1024 and point.y >= 0 and point.y <= 1024
@@ -195,7 +200,7 @@ function benchmarkPoint(int index) returns vec2
195200
mixedQueries++
196201
totalCandidates += candidates
197202
totalCandidates.assertLessThan(linearEdges)
198-
print("Polygon 10000-lookups: mixed=" + mixedQueries +
203+
print("Polygon 1152-lookups: mixed=" + mixedQueries +
199204
", linearEdges=" + linearEdges + ", candidateEdges=" + totalCandidates)
200205
destroy polygon
201206

0 commit comments

Comments
 (0)