-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Greatly Improve Performance of Precomputation #71
base: main
Are you sure you want to change the base?
Conversation
These changes greatly improve the performance of precomputing the map data, as well as laying the groundwork for a vastly improved can_move function.
You can run it for yourself on your own local device.
Note that for development purposes, you may want to add some sorting to the keys, otherwise you will get a different result for data.js every time you run let keys = Object.keys(G.maps);
keys.sort();
let new_maps = {};
for (let x of keys) {
new_maps[x] = G.maps[x];
}
G.maps = new_maps; Inserting this short snippet before the loop in |
Hello, thanks for this PR, can you explain in details what you did, why and the measurements you made to determine the scale of the speed improvement, please? |
Reusing expensive computations (such as a binary search result) and overall improvements to the functions used resulted in a significant increase in performance. The way I measured performance was simply by running |
@Telokis On my machine, precomputing all the maps would take 127975ms, or 128 seconds. With the performance improvements, It went down to 72218ms, or 72 seconds. |
I felt that even though this was a performance improvement in one of the lesser-used parts of the code (map precomputation), since it was an improvement on the |
Ok, I understand, thank you. |
@Telokis It produces exactly the same results. |
I'm a little unsure of the naming of the functions |
I ran a precompute without this PR, figured I'd post the numbers, will post another one for comparison once I check out the, do note I'm getting different timings each time I run it
|
These changes greatly improve the performance of precomputing the map data, as well as laying the groundwork for a vastly improved can_move function.