mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 23:51:55 +00:00
af451be606
## Description: Created test that has astar pathfind from top left to bottom right of giant world map. * Before these changes: took ~950ms * replaced queue with fastqueue library: ~600ms * Changes heuristic to be more greedy (1.1 * dist => 2 * dist): ~90ms Resulting in a roughly 10x improvement. Other paths also saw improvements as well, although not as dramatic. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
37 lines
937 B
TypeScript
37 lines
937 B
TypeScript
import Benchmark from "benchmark";
|
|
import { dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
import { PathFinder } from "../../src/core/pathfinding/PathFinding";
|
|
import { setup } from "../util/Setup";
|
|
|
|
const game = await setup(
|
|
"giantworldmap",
|
|
{},
|
|
[],
|
|
dirname(fileURLToPath(import.meta.url)),
|
|
);
|
|
|
|
new Benchmark.Suite()
|
|
.add("top-left-to-bottom-right", () => {
|
|
PathFinder.Mini(game, 10_000_000_000, true, 1).nextTile(
|
|
game.ref(0, 0),
|
|
game.ref(4077, 1929),
|
|
);
|
|
})
|
|
.add("hawaii to svalbard", () => {
|
|
PathFinder.Mini(game, 10_000_000_000, true, 1).nextTile(
|
|
game.ref(186, 800),
|
|
game.ref(2205, 52),
|
|
);
|
|
})
|
|
.add("black sea to california", () => {
|
|
PathFinder.Mini(game, 10_000_000_000, true, 1).nextTile(
|
|
game.ref(2349, 455),
|
|
game.ref(511, 536),
|
|
);
|
|
})
|
|
.on("cycle", (event: any) => {
|
|
console.log(String(event.target));
|
|
})
|
|
.run({ async: true });
|