Benchmark on the same disk (Ext4)
So let’s start with the results of the benchmarking using the same disk.
We can see that here the native and naive streams methods are a lot slower than the other methods. So lets remove the naive streams method from the graph to have a better view on the other methods :
The first conclusion we can do is that the naive readers is a lot faster than the naive streams. It’s because Reader use a buffer internally and this is not the case in streams. The others methods are closer, so we’ll see with the next sizes what happens.
Here, we have removed the two naive methods because they are too slows compared to the others.
The readers methods are slower than the equivalent streams methods because readers are working on chars, so they must make characters conversion for every char of the file, so this is a cost to add.
Another observation is that the custom buffer strategy is faster than the buffering of the streams and than using custom buffer with a buffered stream or a single stream doesn’t change anything. The same observation can be made using the custom buffer using readers, it’s the same with buffered readers or not. This is logical, because with custom buffer we made 4096 (size of the buffer) times less invocations to the read method and because we ask for a complete buffer we have not a lot of I/O operations. So the buffer of the streams (or the readers) is not useful here.
The NIO Buffer, NIO Transfer and Path strategies are almost equivalent to custom buffer.
Here we see the limits of the simple buffered stream (and readers methods). And another really interesting thing we see is that the native is now faster than buffered streams and readers. Native method must start an external program and this has a cost not negligible. But the copy using the cp executable is really fast and that’s because when the file size grows, the native method becomes interesting. All the other methods except the readers are almost equivalent.
This time we can see that the native copy method is here as fast as the custom buffer streams. The fast method is the NIO Transfer method.
It’s interesting to see that it doesn’t take 100 ms to copy a 50 MB file.
We’ll see with binary now. We’ll directly start with a 5 MB file.
We see exactly the same results as with a text file. The native method start to be interesting. We see precisely that the NIOand Path methods are really interesting here.
We can see that all the methods are really, really close, but the native, NIO Buffer, NIO Transfer and Path methods are the best. Just to be sure of these results, let’s test with a bigger file :
Here we can see that the native method become to be the fastest one. The other method are really close. I thought the NIO Transfer will be normally faster. Due to the size of the file the benchmark has been made only a little number of times, so the number can be inaccurate. We see that he Path method is really close to the other.
The detailed informations (standard deviation, confidence intervals and other stats stuff) are available in the conclusion page.