In a recent startup performance analysis, the initialization of the
rendering infrastructure for Java2D appeared to take up a large percentage
(about 13%) of the overall startup time for a simple AWT app. This time
was spent setting up various elements of the Java2D rendering engine,
such as:
- registering native loops
- registering Java loops
- creating SurfaceData and SurfaceType structures
- creating various PixelFor classes
- setting up default loops and pipes
If we can reduce this time, it could have a large impact on overall startup time for all applications.
Here is the simple AWT app for testing:
------- StartupTest.java --------
import java.awt.Frame;
import java.awt.Graphics;
import javax.swing.JFrame;
public class StartupTest {
public static void main(String args[]) {
for (int i = 0; i < args.length; ++i) {
if (args[i].equals("-awt")) {
Frame f = new AwtFrame();
f.setSize(300, 300);
f.setVisible(true);
} else if (args[i].equals("-swing")) {
JFrame f = new SwingFrame();
f.setSize(300, 300);
f.setVisible(true);
}
}
}
}
class AwtFrame extends Frame {
public void paint(Graphics g) {
System.exit(0);
}
}
class SwingFrame extends JFrame {
public void paint(Graphics g) {
System.exit(0);
}
}