y‰SŽÒzJavaŽ¿–⥑ ..
603:594
08/02/21 23:02:25
>>596
‚ ‚ A‚È‚é‚Ù‚Ç[B‚ÆŽv‚Á‚ÄŽÀ‘•‚µ‚Ă݂½‚çA‹t‚É‚µ’x‚‚È‚è‚Ü‚µ‚½Biƒf[ƒ^‚ͳ‚µ‚“ǂ߂Ă܂µ‚½j
ˆÈ‰º‚̂悤‚ȃR[ƒh‚ð‘‚¢‚ăxƒ“ƒ`ƒ}[ƒN‚µ‚Ä‚àA‚â‚Á‚Ï‚è’x‚‚È‚Á‚Ă܂µ‚½orz
public class ReadTest {
public static final int length = 3800 * 2600;
public static int[] data = new int[length];
public static ByteBuffer buffer;
public static void main(String[] args){
try{
buffer = ByteBuffer.allocateDirect(length * 16);
buffer.order(ByteOrder.LITTLE_ENDIAN);
for(int i = 0; i < 20; i++){ read1(); read2(); read2(); read1(); System.out.print(".");}
long t = System.currentTimeMillis();
for(int i = 0; i < 10; i++){ read1(); }
System.out.println("\r\n" + (System.currentTimeMillis() - t) + " ms");
t = System.currentTimeMillis();
for(int i = 0; i < 10; i++){ read2(); }
System.out.println((System.currentTimeMillis() - t) + " ms");
} catch (Exception e){}
}
public static void read1() throws Exception{
FileInputStream fis = new FileInputStream(new File("hoge"));
FileChannel srcChannel = fis.getChannel();
for(int i = 0; i < 4; i++) fis.read(); // ƒwƒbƒ_
buffer.rewind();
srcChannel.read(buffer); srcChannel.close(); fis.close(); // “ǂݞ‚Ý
buffer.clear();
for(int i = 0; i < length; i++){ data[i++] = buffer.getShort() & 0xffff;}
}
/* read2 ‚͓ǂݞ‚Ý•”•ª‚ªŒÃ‚¢‚Ù‚¤iÈ—ªj */
‚¤[‚ñA•sŽv‹c‚Å‚·‚Ë‚¦B getShort() ‚Í’x‚¢‚ñ‚Å‚µ‚傤‚©BBB
‚Å‚©‚¢‰æ‘œ‚ð‘å—ʂɈ—‚µ‚Ä‚¢‚ÄA“ǂݞ‚Ý‚ª25%‚‚ç‚¢•‚߂Ă¢‚é‚Ì‚ÅA’Z‚‚µ‚½‚¢EE
ŽŸƒy[ƒWÅVƒŒƒX•\ަƒXƒŒƒbƒh‚ÌŒŸõ—ÞŽ—ƒXƒŒˆê——˜b‘è‚̃jƒ…[ƒX‚¨‚Ü‚©‚¹ƒŠƒXƒg¥ƒIƒvƒVƒ‡ƒ“‚ð•\ަ‰É‚‚Ԃµ2ch
4244“ú‘O‚ÉXV/275 KB
’S“–:undef