Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4489049

InputStreamReader performance has severely dropped from 1.3.1 to 1.4

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_2000


      ingrid.yao@Eng 2001-08-07



      J2SE Version (please include all output from java -version flag):

        Tested on: 1.4_beta (build 1.4.0-beta-b65, mixed mode)
                   and
                   1.4_cap_b72 (build 1.4.0-beta_refresh-b72, mixed mode)

      Does this problem occur on J2SE 1.3? Yes / No (pick one)

        No.

      Operating System Configuration Information (be specific):

         Windows 2000SP2, same problem on Solaris Sparc

      Hardware Configuration Information (be specific):

         PIII-800, 256MB RAM, IDE Disk, NTFS filesystem

      Bug Description:

         InputStreamReader performance has severely dropped from 1.3.1 to 1.4
         probably because of the use of NIO.

         Results for JDK 1.3.1:

         C:\java\jdk1.3.1\bin\javaw.exe -classpath "C:\temp\iospeed" IOSpeedTest
         Time for reading (1): 531 ms
         Time for reading (2): 440 ms
         Time for reading (3): 451 ms

         Results for JDK 1.4 public beta:

         C:\java\jdk1.4\bin\javaw.exe -classpath "C:\temp\iospeed" IOSpeedTest
         Time for reading (1): 1753 ms
         Time for reading (2): 1853 ms
         Time for reading (3): 1732 ms

         Results for JDK 1.4 build 72:

         C:\java\jdk1.4cap\bin\javaw.exe -classpath "C:\temp\iospeed" IOSpeedTest
         Time for reading (1): 1041 ms
         Time for reading (2): 992 ms
         Time for reading (3): 1111 ms

         As you can see the public beta is about 4 times slower than 1.3.1 when
         reading files and the latest CAP build still needs more than twice as much
         time for the same task.

      Steps to Reproduce (be specific):

         Run the attached Java program(IOSpeedTest.java) and observe the results
         for JDK 1.3.1 and JDK1.4.

      Test program:

      import java.io.*;
      import java.util.*;

      public class IOSpeedTest
      {
      public static void main(String[] args) throws IOException
      {
      // This test creates a 10 MB text file and afterwars reads it.
      // The speed of reading is much slower with Merlin than with JDK 1.3.1

      String filename = "test.txt";

      String encoding = "US-ASCII";

      Writer writer = new OutputStreamWriter(new FileOutputStream(filename),encoding);
      char[] buffer = new char[10000];
      for (int i = 0; i < 1000; i++) writer.write(buffer);
      writer.close();


      for (int i=1;i<=3;i++)
      {
      long time = System.currentTimeMillis();

      Reader reader = new InputStreamReader(new FileInputStream(filename),encoding);
      while (reader.read(buffer) != -1);
      reader.close();

      System.out.println("Time for reading ("+i+"): " + (System.currentTimeMillis() - time) + " ms");
      }
      }
      }


            mr Mark Reinhold
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: