-
Notifications
You must be signed in to change notification settings - Fork 87
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
Playfield constructor performance #2
Comments
Changed all foreach loops to for loops. Should be a little performance boost. https://github.com/Giswald/silverfish/commit/76b8c5fea4e6bf5266f43f0c1930b5e4be03e0be |
I have used a profiler before on this code, and I can verify the constructor is a huge part of it. To confirm your hypothesis further, if I disable to time it takes to do memory allocation from the profiler, the ctor is no longer the limiting factor. Rather the board evaluation. So I think you are exactly correct, and the boards should be preallocated. However, modifying the AI structure written is probably easier said than done. As soon as I feel comfortable where I am in school i'll have my own AI to work on where i'll likely do exactly that :) ( i probably won't touch the existing ai though) |
oh and another note, iterator seemed only to be a performance block when memory allocation was not accounted for. So I think you won't notice much of a difference until you get rid of the real bottle neck, playfield ctor |
ALSO: sorry i keep writing things you probably keep getting emails. when doing performance, make sure it's still correct by comparing a before and after of the board result. I wrote something as a benchmark in the other repo botmaker and I were using.... we should pull that over here |
@Giswald added you to https://github.com/noHero123/consoleversion |
he biggest performance issue is the Playfield constructor.
dont know if i can change this with adding something like preallocating 5000 (or so) boards, and
just override the existing old/unused playfields in the posmoves-List.
(like:
int i = getNextFreeSpace(posmoves);
posmoves[i].deepCopy(p);
posmoves[i].doAction(a);
instead of
Playfield pf = new Playfield(p);
pf.doAction(a);
)
The text was updated successfully, but these errors were encountered: