Progress! This morning I was able to make some small changes that made a massive difference to the GUI performance of the Java ME client version of one of our products. So, I thought I'd take a moment to write up some notes on it and Mobile development in general:
Basically, in doing some testing and profiling previously, it had become evident that one of the main performance problems in JSR 216 GUI was the use of layout managers in GUI construction (especially the GridBagLayout!). I'd previously addressed all other obvious performance hot spots with optimization or re-implementation - and knew that Layout managers where one of the remain areas to re-factor. All of our GUI components were lightweight and some custom handwritten to perform a specific task. It was tempting to use SWT but wanted to keep the solution generic and AWT/LW based if possible.
Well, after identifying a spurious GridBagLayout that wasn't strictly necessary I was able to re-factor the code to remove it. The impact of this one change has been massive, with something around a 2x to 3x performance speed up and a much more responsive GUI! This is a great return for the effort involved and extent of the change.
One area that still remains is to either implement or port a StringBuilder type class to the JSR 216 platform for faster string concatenation. JSR 216 only supports StringBuffer, while this might not be a problem in most scenarios, some of the custom transparent lightweight widgets I'd written for the product need to do a lot of strings building, so it's performance is critical.
A little digging around has yielded these interesting links that I need to investigate a little more at some point:
Javolution:
http://javolution.org/ - which contains a Java ME library with a fast string builder class (and many other fast classes!).
String builders:
This implementation of a string builder http://www.tailsweep.org/utils/xref/org/tailsweep/utils/builders/StringBuilder.html
RetroWeaver:
and also Retroweaver http://retroweaver.sourceforge.net/ looks interesting. This would enable Java 5 for the mobile platform. However, I have some reservations, mainly todo with issues of performance (Mobile code tends to need to be tight and optimized for the platform). This could be a major win for porting existing code though, well worth keeping in mind.
ProGuard:
I'll also mention that for Java ME development, utilising ProGuard http://proguard.sourceforge.net/ has given noticeable improvements in performance on mobile platforms (as well as smaller Jars).
A word of warning, make sure the end product is tested thoroughly after optimising. Aggressive optimisation can change sometimes change expected functionality - be careful!
--
LW-VCL:
One other thing I came across, that I'm interested to evaluate from a performance perspective, possibly against SWT is the Java LW-VCL, which looks really quite good http://www.lwvcl.com/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment