Hi Garrett,
It's really tough to tell what could be going on without having a
complete testcase to try out. Since in this case it looks like
Graphics2D.fill(Rectangle) is slower in 1.6 than in 1.5, perhaps you
could extract a small microbenchmark that times only that particular
operation, and see if there's a difference between the two releases.
For example, it could be as simple as (in your paintComponent() method):
Rectangle bounds = ...;
long start = System.currentTimeMillis();
for (int i = 0; i < numreps; i++) {
g.fill(bounds);
}
getToolkit().sync();
long end = System.currentTimeMillis();
System.err.println("fill " + bounds + ": " +
((end - start) / numreps) + " avg ms");
Is there any difference between 1.5 and 1.6 if you enable tracing?
-Dsun.java2d.trace=log
And finally, I assume you're displaying to a local Xserver in both
cases?
Thanks,
Chris
On Jan 16, 2007, at 12:07 PM, [EMAIL PROTECTED] wrote:
Hello,
I have a control that allows a child component to be expanded and
hidden from view using an animated effect. Think of opening and
closing a drawer from your desk.
Anyway, the part of the software that creates the animation effect
looks pretty much like this:
[code]
Rectangle bounds = [i]Bounds of component to be animated, initially
collapsed (width = 0)[/i]
JComponent parent = [i]The parent of the animated component[/i]
Graphics2D g = (Graphics2D)parent.getGraphics().create();
while ( animating )
{
long start = System.currentTimeMillis();
g.fill( bounds );
System.err.println( "fill " + bounds + ": " +
( System.currentTimeMillis() - start ) + " ms" );
if ( expanding )
{
bounds.width = bounds.width + 15; /* Creates animating
effect */
}
else /* for collapsing */
{
Rectangle prevBounds = new Rectangle( bounds );
bounds.width = bounds.width - 15;
Area bigArea = new Area( prevBounds );
bigArea.subtract( new Area( bounds ) );
start = System.currentTimeMillis();
parent.paintImmediately( bigArea.getBounds() );
System.err.println( "paintImmediately: " +
( System.currentTimeMillis() - start ) + " ms" );
}
}
[/code]
After all this, the [i]animated[/i] component is added to the
parent at [i]bounds[/i] if expanding or removed prior to this if
collapsing.
My question relates to the performance of these operations. On
JavaSE 1.5.0_08, the lines I have added that print the number of
milliseconds taken in the calls to [i]fill[/i] and [i]
paintImmediately[/i] produce the following output:
[pre]
fill java.awt.Rectangle[x=0,y=277,width=0,height=516]: 2 ms
fill java.awt.Rectangle[x=0,y=277,width=15,height=516]: 0 ms
fill java.awt.Rectangle[x=0,y=277,width=30,height=516]: 1 ms
fill java.awt.Rectangle[x=0,y=277,width=45,height=516]: 0 ms
... Now collapsing
paintImmediately: 4 ms
fill java.awt.Rectangle[x=0,y=277,width=442,height=516]: 0 ms
paintImmediately: 11 ms
fill java.awt.Rectangle[x=0,y=277,width=427,height=516]: 0 ms
paintImmediately: 2 ms
fill java.awt.Rectangle[x=0,y=277,width=412,height=516]: 1 ms
paintImmediately: 2 ms
[/pre]
And that looks pretty good! However, running with 1.6.0 gives me
this output:
[pre]
fill java.awt.Rectangle[x=0,y=277,width=0,height=516]: 2 ms
fill java.awt.Rectangle[x=0,y=277,width=15,height=516]: 19 ms
fill java.awt.Rectangle[x=0,y=277,width=30,height=516]: 20 ms
fill java.awt.Rectangle[x=0,y=277,width=45,height=516]: 20 ms
... Now collapsing
paintImmediately: 6 ms
fill java.awt.Rectangle[x=0,y=277,width=442,height=516]: 16 ms
paintImmediately: 3 ms
fill java.awt.Rectangle[x=0,y=277,width=427,height=516]: 24 ms
paintImmediately: 4 ms
fill java.awt.Rectangle[x=0,y=277,width=412,height=516]: 20 ms
paintImmediately: 4 ms
[/pre]
Which is clearly much slower, at least in the [i]fill[/i]
operation. So, what could be the reason for this?
My platform is a Blade 2500 (Silver) 2xSPARC IIIi, 4GB running
Solaris 8_04. My (perhaps) relevant JVM flags are:
[pre]
-Xms1536m
-Xmx2048m
-Xconcurrentio
-XX:+UseConcMarkSweepGC
-d64
-Dawt.toolkit=sun.awt.X11.XToolkit
[/pre]
Any advice or suggestions would be greatly appreciated!
Thanks,
-Garrett Wampole
[Message sent by forum member 'gwampole' (gwampole)]
http://forums.java.net/jive/thread.jspa?messageID=195131
======================================================================
=====
To unsubscribe, send email to [EMAIL PROTECTED] and include in
the body
of the message "signoff JAVA2D-INTEREST". For general help, send
email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".