Methods Summary |
---|
public static void | createFloats()
for (int i =0; i < FloatArray.length; i++)
FloatArray[i] = ((float) i)/3.2567F;
|
public static void | main(java.lang.String[] args)
createFloats();
niotest();
oldtest();
oldtest2();
niotest();
oldtest();
oldtest2();
niotest();
oldtest();
oldtest2();
niotest();
oldtest();
oldtest2();
|
public static void | niotest()
|
public static void | oldtest()
System.out.println("Testing iterative write");
MyByteArrayOutputStream buf = Buff;
buf.reset();
long time = System.currentTimeMillis();
DataOutputStream wrtr = new DataOutputStream(buf);
wrtr.writeInt(FloatArray.length);
for (int i = 0; i < FloatArray.length ; i++)
wrtr.writeFloat(FloatArray[i]);
wrtr.flush();
wrtr.close();
time = System.currentTimeMillis() - time;
System.out.println("Writing of objects to buffer: " + time);
InputStream istream = new ByteArrayInputStream(buf.getBuffer());
System.out.println(" buffer size: " + buf.getBuffer().length);
time = System.currentTimeMillis();
DataInputStream rdr = new DataInputStream(istream);
int len = rdr.readInt();
float[] allFloats = new float[len];
for (int i = 0; i < len ; i++)
{
allFloats[i] = rdr.readFloat();
}
rdr.close();
time = System.currentTimeMillis() - time;
System.out.println("Reading of objects from buffer: " + time);
System.out.println("Reading idx 17: " + allFloats [17]);
buf = null;
wrtr = null;
istream = null;
rdr = null;
allFloats = null;
System.gc();
|
public static void | oldtest2()
System.out.println("Testing object write");
MyByteArrayOutputStream buf = Buff;
buf.reset();
long time = System.currentTimeMillis();
ObjectOutputStream wrtr = new ObjectOutputStream(buf);
wrtr.writeObject(FloatArray);
wrtr.flush();
wrtr.close();
time = System.currentTimeMillis() - time;
System.out.println("Writing of objects to buffer: " + time);
InputStream istream = new ByteArrayInputStream(buf.getBuffer());
System.out.println(" buffer size: " + buf.getBuffer().length);
time = System.currentTimeMillis();
ObjectInputStream rdr = new ObjectInputStream(istream);
float[] allFloats = (float[]) rdr.readObject();
rdr.close();
time = System.currentTimeMillis() - time;
System.out.println("Reading of objects from buffer: " + time);
System.out.println("Reading idx 17: " + allFloats [17]);
buf = null;
wrtr = null;
istream = null;
rdr = null;
allFloats = null;
System.gc();
|