The BubbleMark Test

I’m starting to evaluate some different frameworks for 2d animation. There are some good ones out there – namely PulpCore, GTGE, and Slick2D. Out of those three, Slick2D interests me the most because it is built on top of LWJGL – so it should eek out maximum performance. However, JavaFX is built on to of JOGL (or Direct3D if running on Windows), so it should also be able to obtain some high performance itself.

I was looking for a somewhat concrete benchmark, and BubbleMark popped up. It is an interesting, if not flawed test case. I say its flawed because the algorithm it uses is expontial, meaning as more elements are added, it gets slower quick. However, it is of some use.

I ran a majority of the tests and my results were the following for 128 balls (keep in mind I have a quad core system):

Framework Frames Per Second CPU Utilization (of quad core)
DHTML – FireFox 3.0.11 33 28%
Silverlight 2.0 69 79%
Flash (Flex) 29 65%
Flash (Flex) – cached as bitmap 98 36%
Java Swing 23 27%
Java Swing (optimized) 178 25%
Java PulpCore 235 27%
JavaFX 1.0 23 30%

The worst news of all was that JavaFX 1.0 clocked in on my system at the lowest – 23 Frames Per Second. At that point, I was really discouraged – almost to the point of switching to PulpCore or Slick2D. However, I thought…let me give it a shot…see if I can ‘optimize’ this benchmark.

Here’s my result:

With my ‘optimized’ version – I achieve 125 Frames Per Second (with 23% cpu utilization) with 128 balls. That’s over a 500% gain in speed. It could probably even be faster had I decided to write some of the logic in Java – but I kept all of the code in JavaFX. As I add more balls to the scene, I get 62 Frames per second with 256 balls, and 21 Frames Per Second with 512 balls.

I mean to use the term ‘optimized’ loosely. I did things slightly different than the original author. I used less resource intensive ways to accomplish the goal. With that said though, the original author wasn’t doing things wrong…he was just using some very powerful attributes within the language. Sometimes, its better to use other approaches to tackle the same problem.

So, what does this mean? Does JavaFX blow SilverLight out of the water in terms of performance? Kick Flash to the curb? No. I wish it were that simple. What it means is that by spending some time optimizing your code, having a good understanding of the language, and realistic expectations…you’ll be able to eek out maximum performance.

All that said though, Slick2D is still a front runner in terms of performance…and I’m thinking of spending some time looking into that. Its just not quite as elegant a library as JavaFX…

Update

I just posted the code, along with an explanation of how the code works.

 

13 Responses to “The BubbleMark Test”

  1. Casper Bang says:

    Impressive optimization.

    It’s probably worth pointing out, that the DHTML results are significant higher when using a state-of-the-art browser such as Crome, with the major difference that you only have to wait 2 sec. for it to start unlike the JavaFX stuff which took a hefty 25 sec. (I had some log data to paste, but the spam filter won’t let me.)

  2. Jmix90 says:

    Why having more than 24 FPS ? (if the human eyes can’t catch them ?

  3. Mathias says:

    Hi,

    Can you post the code you used please ?

    Thx by advance.

  4. Drew says:

    @Casper
    Yes – I have Chrome on my laptop and it was running at 92 Frames Per Second. I’m sure FireFox 3.5 will also increase in performance. Like you said, the load time is significantly smaller, but you still have to worry about IE (which doesn’t have Canvas yet) and the loss of all that ‘extra’ stuff (basically losing all of Java).

    @Jmix90
    While you’re right that you don’t necessarily need more than 24 (although I thought the human eye could see 30 FPS), this is a benchmark trying to show how fast it can render. As you bump up the objects that FPS will drop significantly.

    @Mathias
    Yeah – I’ll be posting the code shortly. I want to go into detail on which optimizations I made and why they helped. It is also probably worth noting that I compiled this for JavaFX 1.1 where as the previous test was compiled to JavaFX 1.0. I’m not sure how much that improved performance, but I am sure it helped some.

    Thanks!

  5. James Ward says:

    Chet Haase and I have discussed in the past why these framerate based benchmarks aren’t very useful:
    http://www.jamesward.com/blog/2008/04/10/bursting-bubbles/

    http://graphics-geek.blogspot.com/2008/04/off-bubblemark.html

    Basically the browser artificially limits the framerate.

    -James

  6. Drew says:

    While that may be true, this can run as a webstart where it is not limited – so can flash and silverlight. Also, what I think this shows is that the idea that JavaFX is slow is really just a myth…

  7. frabber says:

    about the fps.
    I thought in gaming you DO see an increase in fluidity/smoothnes between 60 fps and 30 fps anything beyond 60 goes barely noticeable.

    sub 30 fps is considered mediocre in gaming.
    see for example gpu hardware reviews on http://www.tomshardware.com

  8. Daniel says:

    What are the results (FPS/CPU usage) for Slick?

  9. Drew says:

    Well, I am remote for a few days and running it on my laptop would kind of invalidate the test results. However, if my memory serves me right, it was 2000 frames per second (high cpu usage) for 256 balls.

    It was quite good – but you give up a lot because it is such a lean framework compared to JavaFX…but you get a lot higher performance (at least in this micro benchmark).

  10. Daniel says:

    great, cheers for the info. was nosy, because i am using slick atm for a game. i really like it, its very easy to use, and for those ever used java2d before nearly no learning curve involved.

    2000 FPS, thats out of competition haha maybe someone writes a nice framework on top of slick to make it more abstract…

  11. Drew says:

    Well, there isn’t much competition with it in terms of performance because it is thin layer above OpenGL. However, Slick2D can’t really compete with JavaFX with other aspects – no media performance, the input handling is ‘Java-like’, and there other issues. That’s not to say Slick is bad – it is a great framework for what it was built for…expanding out beyond that though…it isn’t as good.

    If you are writing a game, I would highly recommend Slick2D because it is well built and that’s its purpose. However, as soon as you want to do something a little bit ‘beyond’ that, you might want to start evaluating some other frameworks (PulpCore and JavaFX would be the other two I’d recommend). In the end though, you need to do your own examination of what will work for you – weigh the pros and the cons and all the junk. :-)

  12. Taksan says:

    I did a quick test in my lab and here are my results:

    On a Netbook acer aspire one:
    Slow Atom Processor: 1.3ghz
    128 balls -> 20fps
    64 balls -> 34fps
    32 balls -> 59fps
    CPU goes to 70% utilization

    On a “quite not a gamer” desktop PC:
    AMD athlon 2.2 ghz
    Mainboard-integrated video card
    128 balls -> 58fps
    64 balls -> 88fps
    32 balls -> 111fps
    CPU goes to 90% utilization… but then decreases to 70%

    On “gamer” Desktop PC:
    Dual Core 2 2.8GHz
    nVidia GeForce 9800GT
    128 balls -> 131fps
    64 balls -> 153fps
    32 balls -> 153fps
    CPU goes to 40% utilization

    conclusion (for me): enough for me to make some little games and have fun :)

    Using javafx there is a plus: you can also do 3D graphics with OpenGL

    I was also considering Slick2D (which is great), but javafx looks very interesting. I’m making some tests with both.

  13. Drew says:

    Great info! And please let me know if you make some games – I’d like to try them out!

Leave a Reply