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

JRE 1.3 Startup and Painting performance is much slower than JRE 1.1.8

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs
    • 2d
    • x86
    • windows_nt

      The test case below runs three to four times slower on JDK 1.3 as compared to
      1.1.8. The customer's tests with JProbe show that with JRE 1.3, almost 50% of the time is spent on 3 methods that weren't in 1.1.8: ".Finalizer.", ".Reference Handler." and ".SunToolkit.PostEventQueue-0."

      import java.awt.*;

      class Tester
      {
      public static final int IMG_WIDTH = 600;
      public static final int IMG_HEIGHT = 600;

      public Tester()
      {
      // we use this to compute the total program lifetime before System.exit()
      _programStartTime = getTime();

      _frame = new MyFrame();
      _frame.setBounds( 100, 100, IMG_WIDTH, IMG_HEIGHT );
      _frame.setVisible( true );

      testImage();
      }

      public static void main( String[] args )
      {
      new Tester();
      }

      public void testImage()
      {
      long startTime = getTime();

      Image img = _frame.createImage( IMG_WIDTH, IMG_HEIGHT );
      Graphics g = img.getGraphics();

      draw( g );

      System.out.println( "Drawing on memory image: " + elapsedTime( startTime ) + " ms" );

      _img = img;
      _frame.repaint();
      }

      protected void draw( Graphics g )
      {
      // we do some drawing intensive calls
      for ( int times = 0; times < 5; times++ )
      {
      for ( int i = 0; i < IMG_HEIGHT; i++ )
      {
      g.setColor( new Color( i % 256, 255 - (i % 256), i % 256 ) );
      g.drawRect( i, i, 200, 200 );

      g.setColor( new Color( i % 256, i % 256, 255 - (i % 256) ) );
      g.drawOval( i, IMG_HEIGHT-i, 100, 200 );

      g.setColor( new Color( 255 - (i % 256), i % 256, i % 256 ) );
      g.drawString( "g.drawString()", 0, IMG_HEIGHT-i );
      }

      g.drawLine( 0, 0, IMG_WIDTH, IMG_HEIGHT );
      g.drawLine( IMG_WIDTH, 0, 0, IMG_HEIGHT );
      g.drawLine( IMG_WIDTH / 2, 0, IMG_WIDTH / 2, IMG_HEIGHT );
      g.drawLine( 0, IMG_HEIGHT / 2, 0, IMG_HEIGHT / 2 );
      }
      }

      protected long getTime()
      {
      return System.currentTimeMillis();
      }

      protected long elapsedTime( long startTime )
      {
      return getTime() - startTime;
      }

      class MyFrame extends Frame
      {
      public void paint( Graphics g )
      {
      if ( _img != null )
      {
      long startTime = getTime();

      for ( int times = 0; times < 25; times++ )
      g.drawImage( _img, 0, 0, null );

      System.out.println( "Painting buffered image: " + elapsedTime( startTime ) + " ms" );

      System.out.println( "Program lifetime: " + elapsedTime( _programStartTime ) + " ms" );

      // we can exit here, no need to keep on living if we already computed how long it takes to paint
      System.exit( 0 );
      }
      }
      }

      protected Frame _frame;
      protected Image _img;

      protected long _programStartTime;
      }

            flar Jim Graham
            nrodinsunw Nick Rodin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: