14.1. It's Tougher Than You Might Think

Whether 2D can render frames at a smooth animation rate depends on many factors, including the following:

  • the application itself

  • the JVM implementation

  • the 2D API implementation, which may vary in different JDK releases

  • the operating system

  • the operating system configuration

  • the display hardware (i.e. a video card)

  • the system processor speed

  • the system bus speed

  • available memory

To make things more complicated, the 2D API may perform different operations depending on the display hardware and software that's available.

Finally, the initial release of the 2D API may not be particularly fast. Sun was concentrating hard on getting the API design correct, which means they weren't worrying as much about fixing bugs or making it run fast. Subsequent releases of the JDK should get better and better. And the elusive vaporware called HotSpot is supposed to improve performance dramatically some time in the Java 2 era. See http://java.sun.com/products/hotspot/ for more information.

The bottom line is that it's extremely difficult to pin down exactly what will make an application run quickly or slowly. As you read this chapter, keep your wits about you. Performance analysis and tuning is as much an art as a science. A healthy dose of common sense will take you a long way.

There are tools that will help you analyze your application to find out what parts take the most time. These are called profilers. But as of this writing, profilers aren't available for the ...

Get Java 2D Graphics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.