1. Re: Erasing line drawing
2. Performance: Eek!
1. Re: Erasing line drawing
Ok, well as a workaround for now, I've turned off all dynamic line drawing, for example, I no longer display the AI's losmap as it changes, but only on demand, and then I have a command to erease the lines from the whole map. It's not ideal, but it's ok for now.
I'll give the changes in parameters a whirl, but I did try a couple of values before, and I suspect it's something to do with the parameter named "ret_somethingsomething" being some sort of allocation parameter, that's not being allocated, and hence the segmentation fault?
2. Performance: Eek!
Ok, so I got my ai entirely ported from C# into java, and started to tinker with it. It was very slow, and I started to look into why.
I wrote a performance test, and here is the test and the results:
http://pastebin.com/f29ddf1a0
The result is the number of iterations of the test that were completed in one second.
The control test shows that the basic timing loop runs 50 million times a second, which is fast enough that other test results can be taken directly at face value.
The test of aicallback.getUnitDefs() was excellent. I assume you are caching the results of this somewhere since it is static data?
The test of aicallback.getFriendlyUnits() was pretty low, but I'm going to leave that for the moment, and move on to:
unit.getPos(). This ran 5000 times a second, for a duration of 200 microseconds per getPos call :-O
To put that into perspective, imagine we have a single loop like this, and 200 friendly mobile units:
Code: Select all
for( Unit unit : friendlymobileunits ) {
AIFloat3 pos = unit.getPos();
// do nothing here for now
}
This loop, on its own, with nothing inside it would take:
200 * 200 microseconds = 40000 microseconds = 40 milliseconds to run
30 frames, just for this loop would take 30 * 40 milliseconds = 1.2 seconds :-O
That's .... fairly slow!
The same is true for getUnitDef, but I can cache that per unit. Caching the pos is not really an option.
I assume the speed is a fundamental limitation of JNA, and there is nothing that can be done about it?
Kind of a shame though ....

((((
Hugh