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

JDK1.2RC1 <component>.getToolkit() slowdown due to font loading

XMLWordPrintable

    • 2d
    • x86
    • windows_nt

      /*
      ======================================================================

      Here is a new test program (based on the original) which will
      measure the time spent in getToolkit() and getImage() separately.

      The original program is at the bottom of the Description section.

      tim.bell@Eng 1999-06-25
      */

      /*
        Running on a WinNT 400Mhz P2 system, I've noticed that
        many of the Image operations are much (up to 50%)
        slower while using JDK1.2rc1 as opposed to using
        JDK1.2b4 for the same operations (i.e. getImage
        and drawImage). The example program shows
        loading speed for an image. A similar test using
        drawImage will give similar results, RC1 is
        significantly slower that beta4.


        To run the following src, place a gif image in
        the same directory as ImageSpeed.java (my image
        was 490K in size). Name the gif test.gif. Set up
        your environment to run jdk1.2beta4 and run the
        test. Set up your environment to run jdk1.2rc1 and
        run the test. You should see that jdk1.2rc1 is
        considerably slower...
      */

      import java.awt.*;
      import java.util.Date;
      import java.awt.MediaTracker;

      public class ImageSpeed2 extends Component {

          public static void outputMessage() {
              System.out.println("java.version = " +
                                 System.getProperty("java.version"));
              System.out.println("Operating System Name = " +
                                 System.getProperty("os.name"));
              System.out.println("Operating system architecture = " +
                                 System.getProperty("os.arch"));
              System.out.println("Operating system version = " +
                                 System.getProperty("os.version") + "\n");
          }

          public final static void main(String args[]) {
              ImageSpeed2 imSpeed = new ImageSpeed2 ();
              MediaTracker tracker = new MediaTracker(imSpeed);

              Date toolkitStart;
              Date toolkitEnd;
              Date getImageStart;
              Date getImageEnd;
              long t1, t2, gt;
              long t3, t4, lt;

              outputMessage();

              toolkitStart = new Date();
              Toolkit tk = imSpeed.getToolkit();
              toolkitEnd = new Date();

              getImageStart = new Date();
              // Image im = tk.getImage("test.gif");
              Image im = tk.getImage("test.jpg");
              tracker.addImage(im, 0);
              try {
                  tracker.waitForID(0);
              }
              catch(InterruptedException e) {
                  System.exit(0);
              }
              getImageEnd = new Date();

              t1 = toolkitStart.getTime();
              t2 = toolkitEnd.getTime();
              gt = t2 - t1;
              System.out.println("getToolkit took: " + t2 + " - " + t1 +
                                 " = " + gt + " milliseconds");

              t3 = getImageStart.getTime();
              t4 = getImageEnd.getTime();
              lt = t4 - t3;
              System.out.println("Load test took: " + t4 + " - " + t3 +
                                 " = " + lt + " milliseconds");

              System.out.println("Total time spent: " + (gt + lt) + " milliseconds");
              System.out.println(System.getProperty("line.separator"));
              System.exit(0);
          }
      }
      /* End of ImageSpeed2.java */


      ======================================================================

      Original test program appears below:

      Name: tb29552 Date: 11/18/98


      /*
        Running on a WinNT 400Mhz P2 system, I've noticed that
        many of the Image operations are much (up to 50%)
        slower while using JDK1.2rc1 as opposed to using
        JDK1.2b4 for the same operations (i.e. getImage
        and drawImage). The example program shows
        loading speed for an image. A similar test using
        drawImage will give similar results, RC1 is
        significantly slower that beta4.


        To run the following src, place a gif image in
        the same directory as ImageSpeed.java (my image
        was 490K in size). Name the gif test.gif. Set up
        your environment to run jdk1.2beta4 and run the
        test. Set up your environment to run jdk1.2rc1 and
        run the test. You should see that jdk1.2rc1 is
        considerably slower...
      */

      import java.awt.*;
      import java.util.GregorianCalendar;
      import java.util.Calendar;
      import java.util.Date;
      import java.awt.MediaTracker;

      public class ImageSpeed extends Component {

          public static void outputMessage(){
              System.out.println("java.version = " +
                                 System.getProperty("java.version"));
              System.out.println("Operating System Name = " +
                                 System.getProperty("os.name"));
              System.out.println("Operating system architecture = " +
                                 System.getProperty("os.arch"));
              System.out.println("Operating system version = " +
                                 System.getProperty("os.version") + "\n");
          }

          public final static void main(String args[]) {
              ImageSpeed imSpeed = new ImageSpeed ();
              MediaTracker tracker = new MediaTracker(imSpeed);

              GregorianCalendar c = new GregorianCalendar();
              Date start;
              Date end;
              long t1, t2, t;

              outputMessage();

              start = new Date();
              //Image im = imSpeed.getToolkit().getImage("test.gif");
              Image im = imSpeed.getToolkit().getImage("test.jpg");
              tracker.addImage(im, 0);
              try {
                  tracker.waitForID(0);
              }
              catch(InterruptedException e) {
                  System.exit(0);
              }
              end = new Date();

              c.setTime(start);
              t1 = c.get(Calendar.SECOND) * 1000;
              t1 += c.get(Calendar.MILLISECOND);

              c.setTime(end);
              t2 = c.get(Calendar.SECOND) * 1000;
              t2 += c.get(Calendar.MILLISECOND);

              t = t2 - t1;
              System.out.println("Load test took " + t2 + " - " + t1 + " = " + t + " milliseconds");

              System.exit(0);
          }
      }

      (Review ID: 42621)
      ======================================================================

            pkejriwasunw Parry Kejriwal (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: