-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_95
Name: rm29839 Date: 01/22/98
drawImage is about 5X slower on Java1.2 than it is
on Java 1.1.5. I'm running on a 3-year-old GW2K
Pentium-90, no MMX if that matters.
The following code produces a 400 X 500 blue box with
a diagonal line across it. When I iconize it and
deiconize it, it takes about 80 msec per drawImage
on Java 1.2 and more like 16 on Java 1.1.5. This
is a serious problem for high performance code,
so I'd rank it as a "performance bug".
To see the problem produced in all of its dramatic glory, just resize the box
import java.awt.*;
import java.awt.event.*;
class Test4 extends Frame
{
Image img;
Test4()
{
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.out.println("firing down!");
System.exit(0);
}
}
);
setLayout(null);
}
void init()
{
Dimension d = getSize();
img = this.createImage(d.width, d.height);
if ( img == null )
System.out.println("createImage returned null.");
Graphics g = img.getGraphics();
g.setColor(Color.blue);
g.fillRect(0,0,d.width,d.height);
g.setColor(Color.black);
g.drawLine(0,0,d.width,d.height);
}
public void paint(Graphics g)
{
int reps = 100;
Dimension d = getSize();
if ( img == null )
init();
if ( img == null )
System.out.println("Trouble initializing img");
if ( img != null )
{
long t1 = System.currentTimeMillis();
for (int j=0; j < reps; j++)
{
boolean done =
g.drawImage(img,
0, 0, d.width, d.height,
null);
if ( ! done )
System.out.println("!!! Not Done");
}
long t2 = System.currentTimeMillis();
System.out.println("Frame: " + g.getClip() + " " + (t2-t1)/reps +
" millis ");
}
}
public static void main(String args[])
{
System.out.println("Firing up");
Test4 f = new Test4();
f.setSize(400, 500);
f.show();
}
}
(Review ID: 23783)
======================================================================
- duplicates
-
JDK-4105679 SLOW Graphics performance in 1.2beta2
-
- Closed
-