twpayne/xcscore-js

Add benchmark infrastructure

twpayne opened this issue · 0 comments

The code uses simple brute force algorithms that are O(N^5) in the number of coords, and are CPU bound. Memory usage is O(N^2). It would be good to get a feel for what the practical maximum number of coords is by running some benchmarks.

This should use an existing, established benchmarking package like BenchmarkJS.

Initially, benchmarks should be run for (say) 10-15 coords, and more can be added once the infra.

Here are some input data for , to be used with the cartesianDist function used by the existing tests.

13 coords:

const score = scoreWorldXContest({
	coords: [
		[6, 0],
		[3, 0],
		[0, 0],
		[1.5, 2],
		[3, 4],
		[4.5, 6],
		[6, 8],
		[7.5, 6],
		[9, 4],
		[10.5, 2],
		[12, 0],
		[9, 0],
		[6, 0],
	],
	distKMFunc: cartesianDist,
});
if (score.flightType != "faiTri" || score.score != 51.2) {
	// fail somehow
}

Ideally the benchmark should be run with npm run benchmark or similar, and ideally as part of the GitHub action defined in .github/workflows/main.yml.