文档章节

Java IO与NIO的一些文件拷贝测试

canghailan
 canghailan
发布于 2011/12/09 13:40
字数 2704
阅读 597
收藏 1

测试代码:

package canghailan;

import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * User: canghailan
 * Date: 11-12-9
 * Time: 下午12:38
 */
public class TestIO {
    public static void main(String[] args) throws IOException {
        File[] files = {
                new File("/home/canghailan/java-io-test/1"),
                new File("/home/canghailan/java-io-test/2"),
                new File("/home/canghailan/java-io-test/3")
        };

        int[] bufferSizes = {
                4 * 1024, 8 * 1024, 64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024
        };

        int times = 5;
        for (File file : files) {
            System.out.println("start test " + file.getName());
            long length = file.length();

            for (int bufferSize : bufferSizes) {
                File byBufferedStream =
                        new File(file.getParentFile(), file.getName() + "-BufferedStream-" + bufferSize);
                File byChannelTransfer =
                        new File(file.getParentFile(), file.getName() + "-ChannelTransfer-" + bufferSize);
                File byBufferedChannel =
                        new File(file.getParentFile(), file.getName() + "-BufferedChannel-" + bufferSize);

                for (int i = 0; i < times; ++i) {
                    long start, end, time;

                    start = System.currentTimeMillis();
                    copyByBufferedStream(file, byBufferedStream, bufferSize);
                    end = System.currentTimeMillis();
                    time = end - start;
                    System.out.println("copyByBufferedStream [" + BtoKB(bufferSize) + "]:" +
                            " copy " + length + "Bytes in " + time + "ms" +
                            " @" + getSpeed(length, time) + "KB/s");


                    start = System.currentTimeMillis();
                    copyByChannelTransfer(file, byChannelTransfer);
                    end = System.currentTimeMillis();
                    time = end - start;
                    System.out.println("copyByChannelTransfer[" + BtoKB(bufferSize) + "]:" +
                            " copy " + length + "Bytes in " + time + "ms" +
                            " @" + getSpeed(length, time) + "KB/s");


                    start = System.currentTimeMillis();
                    copyByBufferedChannel(file, byBufferedChannel, bufferSize);
                    end = System.currentTimeMillis();
                    time = end - start;
                    System.out.println("copyByBufferedChannel[" + BtoKB(bufferSize) + "]:" +
                            " copy " + length + "Bytes in " + time + "ms" +
                            " @" + getSpeed(length, time) + "KB/s");

                    System.out.println();
                }
                System.out.println();
            }
            System.out.println();
        }

    }

    private static void copyByBufferedStream(File src, File dst, int bufferSize) throws IOException {
        InputStream in = new FileInputStream(src);
        OutputStream out = new FileOutputStream(dst);

        byte[] buffer = new byte[bufferSize];
        for (; ; ) {
            int count = in.read(buffer);
            if (count == -1) {
                break;
            }
            out.write(buffer, 0, count);
        }

        in.close();
        out.flush();
        out.close();
    }

    private static void copyByChannelTransfer(File src, File dst) throws IOException {
        FileChannel in = new FileInputStream(src).getChannel();
        FileChannel out = new FileOutputStream(dst).getChannel();

        out.transferFrom(in, 0, in.size());

        in.close();
        out.close();
    }

    private static void copyByBufferedChannel(File src, File dst, int bufferSize) throws IOException {
        FileChannel in = new FileInputStream(src).getChannel();
        FileChannel out = new FileOutputStream(dst).getChannel();

        ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
        for (; ; ) {
            int count = in.read(buffer);
            if (count == -1) {
                break;
            }
            buffer.flip();
            out.write(buffer);
            buffer.clear();
        }

        in.close();
        out.close();
    }

    private static float BtoKB(long bytes) {
        return (float) bytes / 1024;
    }

    private static float MStoS(long ms) {
        return (float) ms / 1000;
    }

    private static float getSpeed(long bytesInTime, long time) {
        return BtoKB(bytesInTime) / MStoS(time);
    }
}

测试环境:

canghailan@canghailan-N81Vf:~$ cat /proc/version
Linux version 3.0.0-13-generic (buildd@rothera) (gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) ) #22-Ubuntu SMP Wed Nov 2 13:25:36 UTC 2011
canghailan@canghailan-N81Vf:~$ java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Server VM (build 21.1-b02, mixed mode)

 结论:

1.用Java进行文件拷贝时,Stream与Channel性能上几乎没有差别。

2.Stream的Buffer不是越大越好,如上面数据显示4K,8K,64K,128K,256K时相差不多,1M时性能反有所下降。

 测试方法有错误之处,敬请指正。

 

[注]三个文件为随机选取的40K左右的图像文件,15M左右的PDF文件,130M左右的压缩包文件。

[附]测试结果:

start test 1

copyByBufferedStream [4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[4.0]: copy 41836Bytes in 6ms @6809.2446KB/s

copyByBufferedChannel[4.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[4.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[4.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[4.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [4.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[4.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByBufferedChannel[4.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

 

copyByBufferedStream [8.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[8.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[8.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [8.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[8.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[8.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [8.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[8.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[8.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [8.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[8.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[8.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [8.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[8.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByBufferedChannel[8.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

 

copyByBufferedStream [64.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [64.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [64.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [64.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[64.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [64.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[64.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[64.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

 

copyByBufferedStream [128.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[128.0]: copy 41836Bytes in 5ms @8171.0938KB/s

copyByBufferedChannel[128.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [128.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[128.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[128.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [128.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[128.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByBufferedChannel[128.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [128.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[128.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[128.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [128.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[128.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByBufferedChannel[128.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

 

copyByBufferedStream [256.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[256.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[256.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [256.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[256.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[256.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [256.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByChannelTransfer[256.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[256.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [256.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[256.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[256.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [256.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[256.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[256.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

 

copyByBufferedStream [1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[1024.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[1024.0]: copy 41836Bytes in 3ms @13618.489KB/s

 

copyByBufferedStream [1024.0]: copy 41836Bytes in 3ms @13618.489KB/s

copyByChannelTransfer[1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByBufferedChannel[1024.0]: copy 41836Bytes in 0ms @InfinityKB/s

 

copyByBufferedStream [1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[1024.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByBufferedChannel[1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

 

copyByBufferedStream [1024.0]: copy 41836Bytes in 1ms @40855.47KB/s

copyByChannelTransfer[1024.0]: copy 41836Bytes in 0ms @InfinityKB/s

copyByBufferedChannel[1024.0]: copy 41836Bytes in 2ms @20427.734KB/s

 

 

 

start test 2

copyByBufferedStream [4.0]: copy 14675006Bytes in 46ms @311544.78KB/s

copyByChannelTransfer[4.0]: copy 14675006Bytes in 35ms @409458.88KB/s

copyByBufferedChannel[4.0]: copy 14675006Bytes in 142ms @100922.96KB/s

 

copyByBufferedStream [4.0]: copy 14675006Bytes in 402ms @35649.402KB/s

copyByChannelTransfer[4.0]: copy 14675006Bytes in 255ms @56200.24KB/s

copyByBufferedChannel[4.0]: copy 14675006Bytes in 114ms @125711.055KB/s

 

copyByBufferedStream [4.0]: copy 14675006Bytes in 191ms @75031.734KB/s

copyByChannelTransfer[4.0]: copy 14675006Bytes in 302ms @47453.844KB/s

copyByBufferedChannel[4.0]: copy 14675006Bytes in 287ms @49934.008KB/s

 

copyByBufferedStream [4.0]: copy 14675006Bytes in 226ms @63411.773KB/s

copyByChannelTransfer[4.0]: copy 14675006Bytes in 288ms @49760.63KB/s

copyByBufferedChannel[4.0]: copy 14675006Bytes in 311ms @46080.582KB/s

 

copyByBufferedStream [4.0]: copy 14675006Bytes in 626ms @22893.068KB/s

copyByChannelTransfer[4.0]: copy 14675006Bytes in 35ms @409458.88KB/s

copyByBufferedChannel[4.0]: copy 14675006Bytes in 60ms @238851.02KB/s

 

 

copyByBufferedStream [8.0]: copy 14675006Bytes in 34ms @421501.75KB/s

copyByChannelTransfer[8.0]: copy 14675006Bytes in 28ms @511823.56KB/s

copyByBufferedChannel[8.0]: copy 14675006Bytes in 100ms @143310.61KB/s

 

copyByBufferedStream [8.0]: copy 14675006Bytes in 1144ms @12527.15KB/s

copyByChannelTransfer[8.0]: copy 14675006Bytes in 441ms @32496.734KB/s

copyByBufferedChannel[8.0]: copy 14675006Bytes in 49ms @292470.62KB/s

 

copyByBufferedStream [8.0]: copy 14675006Bytes in 146ms @98157.95KB/s

copyByChannelTransfer[8.0]: copy 14675006Bytes in 430ms @33328.047KB/s

copyByBufferedChannel[8.0]: copy 14675006Bytes in 200ms @71655.305KB/s

 

copyByBufferedStream [8.0]: copy 14675006Bytes in 979ms @14638.469KB/s

copyByChannelTransfer[8.0]: copy 14675006Bytes in 36ms @398085.03KB/s

copyByBufferedChannel[8.0]: copy 14675006Bytes in 49ms @292470.62KB/s

 

copyByBufferedStream [8.0]: copy 14675006Bytes in 859ms @16683.422KB/s

copyByChannelTransfer[8.0]: copy 14675006Bytes in 36ms @398085.03KB/s

copyByBufferedChannel[8.0]: copy 14675006Bytes in 49ms @292470.62KB/s

 

 

copyByBufferedStream [64.0]: copy 14675006Bytes in 28ms @511823.56KB/s

copyByChannelTransfer[64.0]: copy 14675006Bytes in 27ms @530780.0KB/s

copyByBufferedChannel[64.0]: copy 14675006Bytes in 151ms @94907.69KB/s

 

copyByBufferedStream [64.0]: copy 14675006Bytes in 1131ms @12671.141KB/s

copyByChannelTransfer[64.0]: copy 14675006Bytes in 1133ms @12648.773KB/s

copyByBufferedChannel[64.0]: copy 14675006Bytes in 43ms @333280.47KB/s

 

copyByBufferedStream [64.0]: copy 14675006Bytes in 34ms @421501.75KB/s

copyByChannelTransfer[64.0]: copy 14675006Bytes in 232ms @61771.816KB/s

copyByBufferedChannel[64.0]: copy 14675006Bytes in 268ms @53474.105KB/s

 

copyByBufferedStream [64.0]: copy 14675006Bytes in 283ms @50639.793KB/s

copyByChannelTransfer[64.0]: copy 14675006Bytes in 273ms @52494.727KB/s

copyByBufferedChannel[64.0]: copy 14675006Bytes in 273ms @52494.727KB/s

 

copyByBufferedStream [64.0]: copy 14675006Bytes in 284ms @50461.48KB/s

copyByChannelTransfer[64.0]: copy 14675006Bytes in 316ms @45351.457KB/s

copyByBufferedChannel[64.0]: copy 14675006Bytes in 326ms @43960.31KB/s

 

 

copyByBufferedStream [128.0]: copy 14675006Bytes in 27ms @530780.0KB/s

copyByChannelTransfer[128.0]: copy 14675006Bytes in 28ms @511823.56KB/s

copyByBufferedChannel[128.0]: copy 14675006Bytes in 229ms @62581.05KB/s

 

copyByBufferedStream [128.0]: copy 14675006Bytes in 876ms @16359.658KB/s

copyByChannelTransfer[128.0]: copy 14675006Bytes in 35ms @409458.88KB/s

copyByBufferedChannel[128.0]: copy 14675006Bytes in 42ms @341215.72KB/s

 

copyByBufferedStream [128.0]: copy 14675006Bytes in 252ms @56869.285KB/s

copyByChannelTransfer[128.0]: copy 14675006Bytes in 255ms @56200.24KB/s

copyByBufferedChannel[128.0]: copy 14675006Bytes in 311ms @46080.582KB/s

 

copyByBufferedStream [128.0]: copy 14675006Bytes in 264ms @54284.32KB/s

copyByChannelTransfer[128.0]: copy 14675006Bytes in 858ms @16702.867KB/s

copyByBufferedChannel[128.0]: copy 14675006Bytes in 41ms @349538.06KB/s

 

copyByBufferedStream [128.0]: copy 14675006Bytes in 34ms @421501.75KB/s

copyByChannelTransfer[128.0]: copy 14675006Bytes in 248ms @57786.535KB/s

copyByBufferedChannel[128.0]: copy 14675006Bytes in 322ms @44506.4KB/s

 

 

copyByBufferedStream [256.0]: copy 14675006Bytes in 30ms @477702.03KB/s

copyByChannelTransfer[256.0]: copy 14675006Bytes in 28ms @511823.56KB/s

copyByBufferedChannel[256.0]: copy 14675006Bytes in 166ms @86331.695KB/s

 

copyByBufferedStream [256.0]: copy 14675006Bytes in 36ms @398085.03KB/s

copyByChannelTransfer[256.0]: copy 14675006Bytes in 895ms @16012.358KB/s

copyByBufferedChannel[256.0]: copy 14675006Bytes in 42ms @341215.72KB/s

 

copyByBufferedStream [256.0]: copy 14675006Bytes in 36ms @398085.03KB/s

copyByChannelTransfer[256.0]: copy 14675006Bytes in 301ms @47611.496KB/s

copyByBufferedChannel[256.0]: copy 14675006Bytes in 309ms @46378.84KB/s

 

copyByBufferedStream [256.0]: copy 14675006Bytes in 276ms @51924.133KB/s

copyByChannelTransfer[256.0]: copy 14675006Bytes in 305ms @46987.082KB/s

copyByBufferedChannel[256.0]: copy 14675006Bytes in 286ms @50108.6KB/s

 

copyByBufferedStream [256.0]: copy 14675006Bytes in 286ms @50108.6KB/s

copyByChannelTransfer[256.0]: copy 14675006Bytes in 271ms @52882.145KB/s

copyByBufferedChannel[256.0]: copy 14675006Bytes in 312ms @45932.887KB/s

 

 

copyByBufferedStream [1024.0]: copy 14675006Bytes in 69ms @207696.53KB/s

copyByChannelTransfer[1024.0]: copy 14675006Bytes in 27ms @530780.0KB/s

copyByBufferedChannel[1024.0]: copy 14675006Bytes in 167ms @85814.734KB/s

 

copyByBufferedStream [1024.0]: copy 14675006Bytes in 674ms @21262.701KB/s

copyByChannelTransfer[1024.0]: copy 14675006Bytes in 34ms @421501.75KB/s

copyByBufferedChannel[1024.0]: copy 14675006Bytes in 59ms @242899.33KB/s

 

copyByBufferedStream [1024.0]: copy 14675006Bytes in 236ms @60724.832KB/s

copyByChannelTransfer[1024.0]: copy 14675006Bytes in 272ms @52687.72KB/s

copyByBufferedChannel[1024.0]: copy 14675006Bytes in 606ms @23648.615KB/s

 

copyByBufferedStream [1024.0]: copy 14675006Bytes in 268ms @53474.105KB/s

copyByChannelTransfer[1024.0]: copy 14675006Bytes in 35ms @409458.88KB/s

copyByBufferedChannel[1024.0]: copy 14675006Bytes in 68ms @210750.88KB/s

 

copyByBufferedStream [1024.0]: copy 14675006Bytes in 312ms @45932.887KB/s

copyByChannelTransfer[1024.0]: copy 14675006Bytes in 220ms @65141.184KB/s

copyByBufferedChannel[1024.0]: copy 14675006Bytes in 294ms @48745.105KB/s

 

 

 

start test 3

copyByBufferedStream [4.0]: copy 133473839Bytes in 2550ms @51115.902KB/s

copyByChannelTransfer[4.0]: copy 133473839Bytes in 3118ms @41804.215KB/s

copyByBufferedChannel[4.0]: copy 133473839Bytes in 1926ms @67676.81KB/s

 

copyByBufferedStream [4.0]: copy 133473839Bytes in 2006ms @64977.84KB/s

copyByChannelTransfer[4.0]: copy 133473839Bytes in 2390ms @54537.883KB/s

copyByBufferedChannel[4.0]: copy 133473839Bytes in 2560ms @50916.23KB/s

 

copyByBufferedStream [4.0]: copy 133473839Bytes in 2537ms @51377.83KB/s

copyByChannelTransfer[4.0]: copy 133473839Bytes in 2506ms @52013.387KB/s

copyByBufferedChannel[4.0]: copy 133473839Bytes in 2254ms @57828.55KB/s

 

copyByBufferedStream [4.0]: copy 133473839Bytes in 2529ms @51540.35KB/s

copyByChannelTransfer[4.0]: copy 133473839Bytes in 2463ms @52921.453KB/s

copyByBufferedChannel[4.0]: copy 133473839Bytes in 2566ms @50797.17KB/s

 

copyByBufferedStream [4.0]: copy 133473839Bytes in 2552ms @51075.84KB/s

copyByChannelTransfer[4.0]: copy 133473839Bytes in 2944ms @44274.98KB/s

copyByBufferedChannel[4.0]: copy 133473839Bytes in 1911ms @68208.03KB/s

 

 

copyByBufferedStream [8.0]: copy 133473839Bytes in 2427ms @53706.445KB/s

copyByChannelTransfer[8.0]: copy 133473839Bytes in 2572ms @50678.67KB/s

copyByBufferedChannel[8.0]: copy 133473839Bytes in 2522ms @51683.402KB/s

 

copyByBufferedStream [8.0]: copy 133473839Bytes in 2377ms @54836.156KB/s

copyByChannelTransfer[8.0]: copy 133473839Bytes in 2571ms @50698.383KB/s

copyByBufferedChannel[8.0]: copy 133473839Bytes in 2400ms @54310.64KB/s

 

copyByBufferedStream [8.0]: copy 133473839Bytes in 2547ms @51176.11KB/s

copyByChannelTransfer[8.0]: copy 133473839Bytes in 2355ms @55348.426KB/s

copyByBufferedChannel[8.0]: copy 133473839Bytes in 2531ms @51499.625KB/s

 

copyByBufferedStream [8.0]: copy 133473839Bytes in 2394ms @54446.76KB/s

copyByChannelTransfer[8.0]: copy 133473839Bytes in 2494ms @52263.652KB/s

copyByBufferedChannel[8.0]: copy 133473839Bytes in 2336ms @55798.61KB/s

 

copyByBufferedStream [8.0]: copy 133473839Bytes in 2619ms @49769.207KB/s

copyByChannelTransfer[8.0]: copy 133473839Bytes in 2996ms @43506.523KB/s

copyByBufferedChannel[8.0]: copy 133473839Bytes in 1918ms @67959.09KB/s

 

 

copyByBufferedStream [64.0]: copy 133473839Bytes in 2399ms @54333.285KB/s

copyByChannelTransfer[64.0]: copy 133473839Bytes in 2984ms @43681.484KB/s

copyByBufferedChannel[64.0]: copy 133473839Bytes in 1943ms @67084.69KB/s

 

copyByBufferedStream [64.0]: copy 133473839Bytes in 3074ms @42402.586KB/s

copyByChannelTransfer[64.0]: copy 133473839Bytes in 2011ms @64816.285KB/s

copyByBufferedChannel[64.0]: copy 133473839Bytes in 2901ms @44931.246KB/s

 

copyByBufferedStream [64.0]: copy 133473839Bytes in 2125ms @61339.082KB/s

copyByChannelTransfer[64.0]: copy 133473839Bytes in 2321ms @56159.215KB/s

copyByBufferedChannel[64.0]: copy 133473839Bytes in 2343ms @55631.902KB/s

 

copyByBufferedStream [64.0]: copy 133473839Bytes in 2415ms @53973.312KB/s

copyByChannelTransfer[64.0]: copy 133473839Bytes in 2495ms @52242.707KB/s

copyByBufferedChannel[64.0]: copy 133473839Bytes in 2398ms @54355.94KB/s

 

copyByBufferedStream [64.0]: copy 133473839Bytes in 2477ms @52622.344KB/s

copyByChannelTransfer[64.0]: copy 133473839Bytes in 2477ms @52622.344KB/s

copyByBufferedChannel[64.0]: copy 133473839Bytes in 2359ms @55254.58KB/s

 

 

copyByBufferedStream [128.0]: copy 133473839Bytes in 2377ms @54836.156KB/s

copyByChannelTransfer[128.0]: copy 133473839Bytes in 3802ms @34283.414KB/s

copyByBufferedChannel[128.0]: copy 133473839Bytes in 1212ms @107545.83KB/s

 

copyByBufferedStream [128.0]: copy 133473839Bytes in 2565ms @50816.977KB/s

copyByChannelTransfer[128.0]: copy 133473839Bytes in 2431ms @53618.08KB/s

copyByBufferedChannel[128.0]: copy 133473839Bytes in 2461ms @52964.465KB/s

 

copyByBufferedStream [128.0]: copy 133473839Bytes in 2471ms @52750.12KB/s

copyByChannelTransfer[128.0]: copy 133473839Bytes in 2766ms @47124.203KB/s

copyByBufferedChannel[128.0]: copy 133473839Bytes in 2469ms @52792.848KB/s

 

copyByBufferedStream [128.0]: copy 133473839Bytes in 2644ms @49298.617KB/s

copyByChannelTransfer[128.0]: copy 133473839Bytes in 3783ms @34455.6KB/s

copyByBufferedChannel[128.0]: copy 133473839Bytes in 1508ms @86436.04KB/s

 

copyByBufferedStream [128.0]: copy 133473839Bytes in 2272ms @57370.4KB/s

copyByChannelTransfer[128.0]: copy 133473839Bytes in 2835ms @45977.266KB/s

copyByBufferedChannel[128.0]: copy 133473839Bytes in 1910ms @68243.74KB/s

 

 

copyByBufferedStream [256.0]: copy 133473839Bytes in 2519ms @51744.957KB/s

copyByChannelTransfer[256.0]: copy 133473839Bytes in 2437ms @53486.066KB/s

copyByBufferedChannel[256.0]: copy 133473839Bytes in 2844ms @45831.766KB/s

 

copyByBufferedStream [256.0]: copy 133473839Bytes in 1937ms @67292.484KB/s

copyByChannelTransfer[256.0]: copy 133473839Bytes in 3068ms @42485.508KB/s

copyByBufferedChannel[256.0]: copy 133473839Bytes in 1863ms @69965.4KB/s

 

copyByBufferedStream [256.0]: copy 133473839Bytes in 2923ms @44593.07KB/s

copyByChannelTransfer[256.0]: copy 133473839Bytes in 2041ms @63863.574KB/s

copyByBufferedChannel[256.0]: copy 133473839Bytes in 2744ms @47502.023KB/s

 

copyByBufferedStream [256.0]: copy 133473839Bytes in 1996ms @65303.38KB/s

copyByChannelTransfer[256.0]: copy 133473839Bytes in 2904ms @44884.83KB/s

copyByBufferedChannel[256.0]: copy 133473839Bytes in 1930ms @67536.555KB/s

 

copyByBufferedStream [256.0]: copy 133473839Bytes in 2343ms @55631.902KB/s

copyByChannelTransfer[256.0]: copy 133473839Bytes in 2616ms @49826.28KB/s

copyByBufferedChannel[256.0]: copy 133473839Bytes in 2364ms @55137.707KB/s

 

 

copyByBufferedStream [1024.0]: copy 133473839Bytes in 3832ms @34015.016KB/s

copyByChannelTransfer[1024.0]: copy 133473839Bytes in 1350ms @96552.26KB/s

copyByBufferedChannel[1024.0]: copy 133473839Bytes in 2433ms @53574.0KB/s

 

copyByBufferedStream [1024.0]: copy 133473839Bytes in 3905ms @33379.14KB/s

copyByChannelTransfer[1024.0]: copy 133473839Bytes in 1225ms @106404.52KB/s

copyByBufferedChannel[1024.0]: copy 133473839Bytes in 2378ms @54813.098KB/s

 

copyByBufferedStream [1024.0]: copy 133473839Bytes in 3048ms @42764.285KB/s

copyByChannelTransfer[1024.0]: copy 133473839Bytes in 2069ms @62999.297KB/s

copyByBufferedChannel[1024.0]: copy 133473839Bytes in 2462ms @52942.953KB/s

 

copyByBufferedStream [1024.0]: copy 133473839Bytes in 3113ms @41871.363KB/s

copyByChannelTransfer[1024.0]: copy 133473839Bytes in 1963ms @66401.195KB/s

copyByBufferedChannel[1024.0]: copy 133473839Bytes in 2496ms @52221.773KB/s

 

copyByBufferedStream [1024.0]: copy 133473839Bytes in 3672ms @35497.152KB/s

copyByChannelTransfer[1024.0]: copy 133473839Bytes in 1301ms @100188.734KB/s

copyByBufferedChannel[1024.0]: copy 133473839Bytes in 2364ms @55137.707KB/s

© 著作权归作者所有

canghailan

canghailan

粉丝 28
博文 14
码字总数 10765
作品 0
武汉
程序员
私信 提问
tomcat-tomcat bio nio apr 模式性能测试与个人看法

11.11活动当天,服务器负载过大,导致部分页面出现了不可访问的状态、那后来主管就要求调优了,下面是tomcat bio、nio、apr模式以及后来自己测试的一些性能结果。 原理方面的资料都是从网上找...

抢地主
2017/11/04
0
0
Tomcat的BIO、NIO、APR模式对比与性能测试结果

11.11活动当天,服务器负载过大,导致部分页面出现了不可访问的状态、那后来就要求调优了,下面是tomcat bio、nio、apr模式以及后来自己测试的一些性能结果。 原理方面的资料都是从网上找的,...

DemonsI
02/15
0
0
12《Java核心技术》之Java有几种文件拷贝方式?哪一种最高效?

一、提出问题 上一讲我们学习到,NIO 不止是多路复用,NIO 2 也不只是异步 IO,今天我们一起学习 Java IO 体系中,其他不可忽略的部分。 今天我们要讨论的的问题是,Java 有几种文件拷贝方式...

飞鱼说编程
2018/10/25
0
1
Java 200+ 面试题补充② Netty 模块

让我们每天都能看到自己的进步。老王带你打造最全的 Java 面试清单,认真把一件事做到最好。 本文是前文《Java 最常见的 200+ 面试题》的第二个补充模块,第一模块为:《Java 200+ 面试题补充...

王磊的博客
03/08
0
0
漫话:如何给女朋友解释什么是BIO、NIO和AIO?

周末午后,在家里面进行电话面试,我问了面试者几个关于IO的问题,其中包括什么是BIO、NIO和AIO?三者有什么区别?具体如何使用等问题,但是面试者回答的并不是很满意。于是我在面试评价中写...

漫话编程
07/01
0
0

没有更多内容

加载失败,请刷新页面

加载更多

python虚拟环境 virtualenv

python虚拟环境 virtualenv virtualenv为Python项目创建虚拟环境,让不同的项目使用不同的环境,不会产生影响。 virtualenvwrapper是对virtualenv的封装,使用更方便。 安装 pip3 install v...

xiaobai1315
5分钟前
0
0
网络安全-->浅谈UDP协议

简介 UDP-传输控制协议 三大特点: 1、无连接的 2、不可靠的 3、面向数据报 基于UDP的网络协议 1、NFS:网络文件协议 2、TFTP:简单文件传输协议 3、DHCP:动态主机配置...

qrainly
9分钟前
0
0
在进行远程桌面时,经常锁屏怎么解决?

  想要在远程电脑的时候不出现锁屏的现象,首先,你需要将远程电脑设置为允许远程连接。在远程电脑上,打开“设置” 并选择“系统”>“关于”。记下电脑名称。稍后将需要使用此名称。然后,...

takethelas
11分钟前
0
0
小猿圈java之数组

基本数据结构中,数组是很重要的,这篇小猿圈加加对数组详解一席,具体使用,在学习过程中有困惑的朋友,可以看一下加加的这篇文章,看到就是赚到,让我们一起看看吧。 一、数组的基本使用 ...

小猿圈加加
12分钟前
0
0
如何基于日志,同步实现数据的一致性和实时抽取?

7月25日晚8点,线上直播,【AI中台——智能聊天机器人平台】,点击了解详情。 一、背景 事情是从公司前段时间的需求说起,大家知道宜信是一家金融科技公司,我们的很多数据与标准互联网企业不...

宜信技术学院
22分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部