Le Tue, 24 Jan 2006 09:30:27 +0000, Chris Uppal a écrit :
John said:
It depends on how you define "the job". I have trouble believing that
one invocation of the constructor you are using takes a
human-discernible amount of time, [...]
Especially since the conversion from UTF16 (BE or LE) is as near trivial
as charset decoding can possibly get.
I second John's request for more information. If you don't have profiling
data then you must have some other timing information. What is it ?
John, Chris, thanks for your replies.
I have parsed the application the more basically I can do : difference
between getTimeInMillis() from end to begin of prog.
I stripped out all the real stuff to keep only the parts I suspected to
be the bottleneck of the application. The remaining code is :
/////// CODE //////
import java.io.FileInputStream;
import java.nio.MappedByteBuffer;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.GregorianCalendar;
public class Test{
public static void main(String args[]){
int sum = 0;
String fileName="/tmp/test.bin"; //file size is 22MB : 22645840
GregorianCalendar start=new GregorianCalendar();
try {
FileInputStream fs = new FileInputStream(fileName);
FileChannel fchan = null;
fchan = fs.getChannel();
int sz = (int)fchan.size();
MappedByteBuffer mbuf = null;
mbuf =
fchan.map(FileChannel.MapMode.READ_ONLY,
0, sz);
byte tpb = 0;
ByteBuffer ibuf = mbuf.asReadOnlyBuffer();
byte tmpBuf[]=new byte[212];
while (ibuf.hasRemaining()) {
ibuf.get(tmpBuf);
String Part1=new String(tmpBuf, 20, 54, "UTF-16BE"); // comment this line out for profiling
String Part2=new String(tmpBuf, 74, 132, "UTF-16BE"); // comment this line out for profiling
}
}catch(Exception e){e.printStackTrace();}
System.out.println("Duration in ms : "+(new GregorianCalendar().getTimeInMillis()-start.getTimeInMillis()));
}
}
/////// END OF CODE //////
Platform :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
Linux 2.6, debian sarge, via processor & chipset.
If i launch the prog the result is :
Duration in ms : 4618 (no significant differences between tests)
Then, when i comment out the two lines flagged above the result is :
Duration in ms : 383 (no significant differences between tests)
The 106820 loops are processed faster on... faster computers
but I must
keep this platform. Since the 4+ seconds must be added to uncompressible
other ones and a human is waiting for a result i'll appreciate any
help to reduce this bottleneck.
Eric
PS : sorry for the 3 lines of more than 80 chars.