What type of graphics images are being displayed? This is often system/video dependent. Try running this performance test on both platforms:
// Program : TestGraphics.java
// Description: Test performance of graphics types.
// Notes : Use ‘java -Xcomp’ to run this app. This option will
// force JIT-compilation at startup, instead of letting
// HotSpot decide when and what to compile. Without it,
// HotSpot may trigger compilation at an unknown or
// unexpected point, invalidating the elapsed times due
// to a flurry of JITC-ing. It may also be useful to run
// with -Xint and -Xmixed to show how much is interpreter
// cost and how much is graphics rendering cost.
import java.awt.;
import java.awt.image.;
public class TestGraphics
{
static final int WIDTH = 700,
HEIGHT = 700;
static final int COUNT = Math.min(WIDTH,HEIGHT)/2;
static final String[] sImageNames =
{
"TYPE_INT_RGB (HotSpot warm-up, throw away)",
"TYPE_INT_RGB",
"TYPE_INT_ARGB",
"TYPE_INT_ARGB_PRE",
"TYPE_INT_BGR",
"TYPE_3BYTE_BGR",
"TYPE_4BYTE_ABGR",
"TYPE_4BYTE_ABGR_PRE",
"TYPE_USHORT_565_RGB",
"TYPE_USHORT_555_RGB",
"TYPE_BYTE_GRAY",
"TYPE_USHORT_GRAY",
"TYPE_BYTE_BINARY",
"TYPE_BYTE_INDEXED",
"native CompatibleImage"
};
static final int[] sImageConstants =
{
BufferedImage.TYPE_INT_RGB,
BufferedImage.TYPE_INT_RGB,
BufferedImage.TYPE_INT_ARGB,
BufferedImage.TYPE_INT_ARGB_PRE,
BufferedImage.TYPE_INT_BGR,
BufferedImage.TYPE_3BYTE_BGR,
BufferedImage.TYPE_4BYTE_ABGR,
BufferedImage.TYPE_4BYTE_ABGR_PRE,
BufferedImage.TYPE_USHORT_565_RGB,
BufferedImage.TYPE_USHORT_555_RGB,
BufferedImage.TYPE_BYTE_GRAY,
BufferedImage.TYPE_USHORT_GRAY,
BufferedImage.TYPE_BYTE_BINARY,
BufferedImage.TYPE_BYTE_INDEXED
};
// This is a simple test that does setColors and fillRects
static void recTest(BufferedImage bi)
{
Graphics g2D = (Graphics2D) bi.getGraphics();
for (int i=0; i<COUNT; i++)
{
if (i%2 == 0 )
{
g2D.setColor(Color.black);
}
else
{
g2D.setColor(Color.red);
}
g2D.fillRect(i,i, WIDTH-i,HEIGHT-i);
}
}
public static void main(String[] args)
{
long startTime;
long[] elapsedTime = new long[sImageConstants.length + 1];
// Allocate 14 different buffered images to cross-compare
BufferedImage[] bis = new BufferedImage[sImageConstants.length + 1];
for (int i=0; i<sImageConstants.length; i++)
bis[i] = new BufferedImage(WIDTH, HEIGHT, sImageConstants[i]);
// Include native type:
bis[sImageConstants.length] = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(WIDTH, HEIGHT);
// Compute and print performance
System.out.println("Simple Graphics Performance Example");
System.out.println("Time\tImage Type\n----\t----------");
for (int i=0; i<=sImageConstants.length; i++)
{
startTime = System.currentTimeMillis();
recTest(bis[i]);
elapsedTime[i] = System.currentTimeMillis() - startTime;
System.out.println(elapsedTime[i] + "\t" + sImageNames[i]);
}
// Doing graphics may start the AWT event-thread, thereby preventing
// a return from main() from causing an exit. So, always force an exit.
System.exit(0);
}
}