From: Raimar F. <hawk@B205a.WH8.TU-Dresden.De> - 2000-10-03 00:11:34
|
On Mon, Oct 02, 2000 at 05:24:15PM +0200, Ulrich Kuhn wrote: > On Mon, 2 Oct 2000, Raimar Falke wrote: > > > On Mon, Oct 02, 2000 at 12:54:09AM +0200, Raimar Falke wrote: > > > > I should stop repling to myself. > > > > > I will do some tests. > > > > Ok the attached version will load the sample score just fine. If there are > > no complains Deming can put a new version together. > > A few littleties: > For memory's sake and as it is my job :-) I recommend the following patch > for DataTypeInfoForOneTurn.java: I didn't considers because DataTypeInfoForOneTurn is the "innermost" class. There are 500*27 instances of this class. With your proposal there can be 500*27*3=40500 grow operations. I did some rough calculations and came to the conclusion the saved memory isn't worth it. The difference between the classes with 1 (worst case) and 32 players are: 500*27*(32-1)*4=1674000 bytes. > 27,28c27,28 > < data = new int[FreecivConstants.MAX_NUM_PLAYERS]; > < defined = new boolean[FreecivConstants.MAX_NUM_PLAYERS]; > --- > > data = new int[4]; > > defined = new boolean[4]; > 44a45 > > if (player >= data.length) grow(Math.max(data.length*2, player)); > 47a49,58 > > > > private void grow(int newSize) { > > int[] newArray = new int[newSize]; > > System.arraycopy(data, 0, newArray, 0, data.length); > > data = newArray; > > boolean[] newDefined = new boolean[newSize]; > > System.arraycopy(defined, 0, newDefined, 0, defined.length); > > defined = newDefined; > > } Could you please make unified diffs. It is more readable. Just supply "-u" to the command line. > This will save memory consumption by factor 0 to 8 (32 to 4 players in > log). To my surprise I was not able to measure any performance loss. So > System.arraycopy must be extremely fast. It is native. If we use it a lot we should maybe try to measure it. Something like "on a P2-400: arraycopy() can copy a 1000 int array in 1.2ms" > A $@ in the civlog script (for starting CivLog under unix) would enable > the user to start CivLog with a scorelog file as parameter. I don't use it. java -jar CivLog.jar scorelogs/superbig.log works fine. > BTW: Raimar: Your CLTimer may be unprecise on certain platforms. For > example in windows 9x Java is not able to be more precise than 50 or 60 ms > when invoking System.currentTimeMillis(). So when repeatedly invoking the > start and stop methods you may get many 50ms entries where only 100ns is > used... It is more or less a quick hack. It is better than leaving longs all over the place. I have no control over the time resolution on certain platforms. However IMHO the code for CLTimer is correct. Raimar -- "We just typed make..." -- Stephen Lambrigh, Director of Server Product Marketing at Informix, about porting their Database to Linux |