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

paint performance recedes in JDK 9 and above

XMLWordPrintable

    • 9
    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      same result on different hardware and Windows 7

      A DESCRIPTION OF THE PROBLEM :
      paint works fine for versions up to 1.8.0_192 but degrades on recent versions e.g. 11.0.1.
      paint method take 60(!) times longer to complete.

      REGRESSION : Last worked in version 8u192

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile and run using jdk1.8.0_192
      (compile and ) run using jdk-11.0.1

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      similar performance for jdk1.8.0_192 and jdk-11.0.1

      ACTUAL -
      jdk-11.0.1 takes 60 times longer than jdk1.8.0_192


      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;

      class GraphicsPaintPerformance extends Frame // javax.swing.JFrame
      {
         int [] x = null;
         int [] y = null;
         
         public static void main( String [] args )
         {
            new GraphicsPaintPerformance();
         }
         
         GraphicsPaintPerformance()
         {
            int N = 20000;
            x = new int[N];
            y = new int[N];
            
            for( int i = 0; i < N; i++ )
            {
               x[i] = (int)( 500 * Math.random() + 50 );
               y[i] = (int)( 500 * Math.random() + 80 );
            }
            
            setSize( 600, 630 );
            setVisible( true );
            
            addWindowListener( new WindowAdapter()
            {
               public void windowClosing( WindowEvent we )
               {
                  System.exit(0);
               }
            });
         }
         
         public void paint( Graphics g )
         {
            long start = System.currentTimeMillis();
            
            int n = x.length;
            for( int i = 1; i < n; i++ )
            {
               g.drawLine( x[i-1], y[i-1], x[i], y[i] );
            }
            
            g.setColor( Color.WHITE );
            g.fillRect( 250, 280, 100, 100 );
            
            
            g.setColor( Color.BLACK );
            g.drawString( 0.001 * ( System.currentTimeMillis() - start ) + " s", 280, 335 );
         }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      stay with jdk1.8.0_192

      FREQUENCY : always


            kaddepalli Krishna Addepalli
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: