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

java.lang.String byte/char conversions very slow (win32, 1.2fcs-D)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.2.0
    • 1.2.0
    • core-libs
    • None
    • 1.2fcs
    • generic
    • generic
    • Not verified

      Last night while working on something else I noticed a huge slowdown in the
      cost of the String constructors that take byte arrays and the String.getBytes
      methods, which convert characters back into bytes. This affects Win32 only,
      and is quite serious. The following program:

          import java.util.Random;

          public class E2 {

      public static void main(String[] args) throws Exception {
      int n = 100000;
      Random r = new Random(0);
      int s = 0;
      for (int i = 0; i < n; i++) {
      byte[] b = Integer.toString(r.nextInt()).getBytes();
      s += b[0];
      }
      System.out.println(s);
      }

          }

      runs on my 266MHz P2 machine in 2.19s using 1.2beta4 and in 45.47s using
      1.2fcs-D. This problem may also explain the recent ~10% slowdowns in two
      string-intensive SPEC benchmarks, db and javac.

      This problem only arises if you don't have i18n.jar installed. Since we expect
      many Win32 users not to have this jar file, this problem must be fixed for FCS.

      -- mr@eng 8/7/1998

            mr Mark Reinhold
            mr Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: