Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions wurst/math/PolygonTests.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,17 @@ function benchmarkPoint(int index) returns vec2
(polygon.classify(vec2(96, 96)) == polygon.classifyLinear(vec2(96, 96))).assertTrue()
destroy polygon

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

Expand Down