Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Bubblemark

 

This posting says some nice things about JavaFX, but also points out that in its current incarnation its performance is lacking:

The first thing you’ll notice is that it’s very slow. The demo takes a very long time to load and start, and real time performance is disappointing. Here is how it compares:

JavaFX — 14 fps
Firefox + Silverlight (JavaScript) — 56 fps
Firefox + Flex — 62 fps
Adobe AIR — 62 fps
Firefox + Silverlight (CLR) — 99 202 fps (update: 202 fps after fixing main timer’s latency)

(All tests were performed on Pentium M 1.7 machine under Windows XP SP2)

It is 4.4x slower than Flash and 7x 14x slower than Silverlight (CLR-based variant).

On a positive side, development with JavaFX is fun, the language is very compact and efficient for building complex dynamic layouts. There is a great converter to JavaFX from SVG format and JavaFXPad is done nicely too.

If only it were 5x faster!

Of course, our intention is to provide hardware-accelerated vector graphics and compile JavaFX script to JVM bytecode getting the full benefits of the hotspot virtual machine, and to provide an improved deployment system, and we're working on that.

The Bubblemark performance described above is caused by

  • Download time - size of the deployment unit - The bubblemark JNLP doesn't use pack200 compression so the download of the JavaFX runtime + the app is ~2.1 MB
  • Performance of the JavaFX interpreter in doing the collision detection - which is currently probably 50-100 times slower than doing it in Java
  • Lack of caching or hardware acceleration of the vector graphics and gradients that make up the ball
Eventually, a production-quality JavaFX will automatically provide these benefits but in the meantime because JavaFX builds on Java, it's possible to get respectable performance for Bubblemark by making a few minor changes:
  1. Use pack200 compression for the Jar files
  2. Do the collision detection in Java code
  3. Cache the vector graphic at the application level - since once created it's static in this application

Below's a version of Bubblemark in JavaFX that does that.

Here's a link to the source code