Beispiel #1
0
  @Test
  public void test() {
    File file = ResourceLoader.getFile("all200000.txt"); // all200000.txt
    int time = 100;
    assert file.exists();
    TimeCounter tc = new TimeCounter();
    byte[] bytes = getBytes(file);
    tc.start();
    for (int i = 0; i < time; i++) {
      bytes = getBytes(file);
    }
    tc.stop();
    System.out.println(
        "ByteArrayOutputStream time cost:" + tc.timePassed() + ",byte length:" + bytes.length);

    byte[] bytes2 = getBytes2(file);
    tc.start();
    for (int i = 0; i < time; i++) {
      bytes2 = getBytes2(file);
    }
    tc.stop();
    System.out.println(
        "ByteArray of List time cost:" + tc.timePassed() + ",byte length:" + bytes2.length);
    byte[] bytes3 = Files.getBytes(file);
    tc.start();
    for (int i = 0; i < time; i++) {
      bytes3 = Files.getBytes(file);
    }
    tc.stop();
    System.out.println("time cost:" + tc.timePassed() + ",byte length:" + bytes3.length);
    assert Arrays.equals(bytes, bytes2);
    assert Arrays.equals(bytes, bytes3);
  }