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

jdk 1.4.2_04 performance string handling

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2_04
    • hotspot
    • sparc
    • solaris_9

      jdk 1.4.2_04 performance on Solaris x86 is double the performance on Sparc
      Time on Toshiba laptop Tecra 8100 600 MHz Solaris x86 9 :
      5684
      Time on 280R 750 MHz Solaris 9:
      10310


      Example used:

      import java.io.*;


      class Test {

      public static void main (String args[]) {

      Test t = new Test(args);
      }


      Test(String [] args) {
                      long millis;
                      StringBuffer buffer = null;

      if (args.length==1) {
      System.out.println("Priming...");
      for (int i=0; i<15000; i++) {
      buffer = test(1);
      }
      }


      System.out.println("Press return to continue.\n");
      try {
      int i = System.in.read();
      } catch (IOException e) {
      System.out.println(e);
      }

      System.out.println("Testing...\n\n");
                      millis = System.currentTimeMillis();
      buffer = test(1000000);
                      System.out.print("Durata: ");
                      System.out.println((System.currentTimeMillis()-millis));

      }





      private StringBuffer test(int iterations) {
      StringBuffer buffer = null;

      for(int k = 0 ; k < iterations; k++)
      {
      buffer = new StringBuffer(" ");
      String a1 = "cgghghghghghhhhhgd";
      String a2 = "12";
      String a3 = "XXXXXXX";
      String a4 = "";
      String a5 = "";
      String a6 = "-ggggggggggggg";
      String a7 = "-";
      String a8 = "ggggg-";
      char c;
      int i;
      int j = 0;


      String str = a1;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));
      j += 20;
      str = a2;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));
      j += 20;
      str = a3;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));
      j += 20;
      str = a4;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));
      j += 20;
      str = a5;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));
      j += 20;
      str = a6;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));
      j += 20;
      str = a7;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));
      j += 20;
      str = a8;
      for(i=0; i<str.length(); ++i) buffer.setCharAt(j+i, str.charAt(i));


      }
      return buffer;

      } // end method test

        private static void delay(int time) {
          try { Thread.sleep(time);
                      } catch (InterruptedException e) {
                        System.out.println("Interrupted!");
                              e.printStackTrace();
                      }
        }


      }

            collins Gary Collins (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: