Duplicate :
|
Name: nt126004 Date: 04/29/2003 FULL PRODUCT VERSION : not version-related FULL OPERATING SYSTEM VERSION :not OS-related A DESCRIPTION OF THE PROBLEM : In testing I found that using LITTLE_ENDIAN arrays showed no improvement on an Intel machine. Copying 1.6M ints was no faster with the native order (270 to 280 millis) than with the BIG_ENDIAN order. If the copy were done with a standard C library copy it would take advantage of the fact that copying an array is a bit of setup and then a single bulk copy instruction. On the 386 (last time I checked) that copy moved one word per cycle. Assuming no improvement in that area, copying 1.6M words should take 4 millis, not 270 or 280. Ask the programmer who did System.arraycopy(). He got it right. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1.test code posted below 2.change constant to BIG_ENDIAN and retest 3. EXPECTED VERSUS ACTUAL BEHAVIOR : BIG_ENDIAN order requires a byte-by-byte flip on a LITTLE_ENDIAN box. LITTLE_ENDIAN only needs copying an area of RAM. Expected 2 orders of magnitude speed increase. Got zero. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public static void main( String[] args ) { public static final int K = 1024; byte[] buf = new byte[ 6400 * K ]; int ilen = buf.length / 4; ByteBuffer bb = ByteBuffer.wrap( buf ); bb.order( ByteOrder.LITTLE_ENDIAN ); IntBuffer ib = bb.asIntBuffer(); int[] ints = new int[ ilen ]; for ( int i = 0; i < ilen; i++ ) ints[i] = i; long start = System.currentTimeMillis(); ib.put( ints ); long stop = System.currentTimeMillis(); System.out.println( "time=" + (stop - start) ); System.exit( 0 ); } // end of main() ---------- END SOURCE ---------- (Review ID: 181086) ======================================================================