I'm busy writing SQL so mundane my brain is trying to escape from my
skull. In other words, I decided to write a little IO test program
to see what results I get. Actually, I was pretty blown away by the
results. My test involves writing a 50MB file and then reading it
back in. I realise that the read will be cached by the OS, but I
think this is a useful measure of raw OS memory to Java memory. I
tested my 1.5GHz Powerbook G4 with a 5400rpm against my Athlon 64 3200
+ (its brand new so I expect it to give the Mac a spanking).
My results are:
Mac:
Write: 26.3 MB/s
Read: 81.7MB/s
Windows:
Write: 40MB/s
Read: 421MB/s
I'm no expert in these matters, but that write looks pretty quick to
me. In fact, it looks the same transfer speed as I get when copying
large files to 800 Firewire drive. The read is pretty interesting.
I would expect it to be a bit faster. The Windows machine is a
beast; the drives are faster, the bus is faster, the memory is
faster. So I don't know how much we draw from this. We would really
need someone with G5 to test.
Sample program attached. Please berate me if there's anything wrong
with it.
import java.io.*;
public class IOTest {
private static final long testFileSize = 50 * 1024 * 1024;
private static final int BUF_SIZE = 8192;
private static final byte[] chunk = new byte[BUF_SIZE];
static {
for (int i = 0; i < chunk.length; i++) {
chunk[i] = (byte) (Math.random() * 255);
}
}
public static void main(String[] args) throws IOException {
File writeFile = File.createTempFile("vmBench", ".writeFile");
FileOutputStream fos = new FileOutputStream(writeFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
long testStart = System.nanoTime();
writeChunkOfData(bos);
long testFinish = System.nanoTime();
File readFile = new File(writeFile.getPath());
FileInputStream fis = new FileInputStream(readFile);
BufferedInputStream bis = new BufferedInputStream(fis);
private static void readChunkOfData(BufferedInputStream bis)
throws IOException {
byte[] readBuffer = new byte[BUF_SIZE];
while (bis.read(readBuffer) != -1);
}
private static void writeChunkOfData(BufferedOutputStream bos)
throws IOException {
long bytesWritten = 0;
while (bytesWritten < testFileSize) {
int len = (int) Math.min(BUF_SIZE, (testFileSize -
bytesWritten));
bos.write(chunk, 0, len);
bytesWritten += len;
}
bos.flush();
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden