You can webstart or download source. (Updated Here)
Source requires JGoodies Forms.

I’ve been working for a few days on trying to get the CPU usage down on Romain Guy’s Follow The Curves Demo and i believe i’ve gotten it to a semi-acceptable level.

I’ve done this by implementing Dim’s gradient panel from the blogs comments, this buffers the rather complex gradient on the background, hence stopping it from redrawing every single time we paint he animation and it took quite a load off the CPU. Next i went about changing some of the rendering hints to some lower quality values and i honestly can’t see a differnece. I then started to do some minor code changes which envolved chagning all the floats to doubles (it seems to lightly increase performance) and also changing all divide by 2 references to right shift 1 and the multiply by 2 to left shift 1.

Now on starting it’s using about 46% of my work box’s CPU (Celeron 2ghz) and after running for about 5 seconds it hovers around the 8% / 13% mark and then after another 3 seconds it’s ranging from 0% / 3%. Quite significant improvements for a demo that was starting at bout 70% and hovering around 50% still after a long period of time.

2 thoughts on “3..2..1.. Ignition

  1. Dude,

    That right shift vs. divide by 2 thing so old it’s a meaningless optimization. In the way old days of C compilers this may have had some effect. But compilers since the mid-80’s have had good optimizers that know the instruction sets of our CPUs far better than we do. The optimizers translate an internal representation of the code into the best instructions taking into account global register allocation, pipelining, and the execution cost of each instruction.

    Instead of obfuscating the code with this stuff just make the code readable.

  2. Hey Neil

    Thanks for your input, it was just something i tried to reduce the CPU load, and it seemed to reduce it a MINUTE amount. So i kept it in there.. i was kind of aware the JVM might due these optimisations on the fly when executing the classes, but not to sure, so i tried it.

    Anyway as i said, it seemed to make a diff so i left it in there..

    Working on something atm to make it faster again (thanks to romain for the tips), hopefully i’ll get it up here in a few days (if i get time to work on it) and yeah.. I’ll clean that mess up before i stick it up for everyone to view this time. Only thought about how messy my coding is over the weekend when i was sitting at home looking at it.

Comments are closed.