The Mudcat Café TM
Thread #39545   Message #567846
Posted By: Jon Freeman
08-Oct-01 - 08:36 PM
Thread Name: BS: Help Ask Sam Forum
Subject: RE: BS: Help Ask Sam Forum
Well Tech Impaired I got the information I needed to get the .ask file into a text file and made certain other choices but I am struggling with Java at the moment, a) getting used to parts of the language and b) trying to see if I can get some degree of performance when I think I know what I'm doing. Maybe I don't...

Here is one for Mudguard. On the first time of excecution on my machine, this code can take 20 seconds to complete but on subsequent execution, it will complete in about 1 second (BuffRandomAccessFile is my subclass of RandomAccessFile and all I'm trying to do is read through the file one character at a time to see how quickly I can do it BTW).

   void readFile(){    

int EOF;
char Ch;
try {
BuffRandomAccessFile InFile = new BuffRandomAccessFile
("D:\\JBuilder\\MyClasses\\JavaDT\\DT.dat","r",4096);

do {
EOF = InFile.BuffNextChar(Ch);
}
while (EOF != -1);
System.out.println("Job Done");
}
catch (Exception f)
{ f.printStackTrace(); }
}

At first, I thought it might have been something to do with the file system and maybe bits were stored in a buffer in the computer but no - adding something like this:

if (FirstCall != 1){
FirstCall = 1;
return;
}

at the start of the method body to ensure that the method just returns on the first call results in the full run of the method excecuting in 1 second every time - sort of like the initial method call adds some overhead to everything contained in the method. Weird?

Jon