I've read an answer 2 years ago about UiBinder performance https://stackoverflow.com/a/3755675/1067931 And decided to put it to a test.
I built a really complicated layout with many buttons, and panels one inside another. version 1 had the layout built purely in UiBinder xml, while version 2 purely programatically.
I deployed both versions to App Engine and ran both versions, while clearing browser cache before each run. Version 1 (UiBinder) loaded after ~12 seconds, while Version 2 after ~3 seconds, so it really discouraged me from using UiBinder. Did you have different impressions?
UiBinder, just like any GWT generator, generates Java code. So first, go read what's generated and compare that to what you'd be writing by hand (pass the -gen
option to the GWT Compiler or DevMode to make it write the generated code down to disk).
Where UiBinder shines is with HTMLPanel
and I18N, because it makes the code so much more readable than when written in Java.
GWT 2.5 also introduces IsRenderable
and RenderablePanel
as an experimental feature that however can boost your perfs under some conditions (they made it for boosting perfs of Orkut). Again, UiBinder makes it easy to use (IsRenderable
otherwise requires calling its methods in the appropriate order, and at the appropriate time to get maximum performances; UiBinder makes this transparent). There unfortunately are no other IsRenderable
widgets than RenderablePanel
, so it only helps if you create your own widgets that implement IsRenderable
; and IsRenderable
operates at a very low level.
Generally speaking, UiBinder shouldn't perform slower than hand-written code (for the equivalent arrangement of widgets of course). When people say UiBinder performs better (outside IsRenderable
) is that it encourages you to use HTMLPanel
rather than panels for layout. For instance, an HTMLPanel
containing an HTML <table>
or a set <div>
s performs way faster than a FlexTable
or a bunch of FlowPanel
s (assuming you won't need to modify the layout dynamically).
It seems intuitively right to me, that UiBinder-Code can lead to longer start-up times. here is why:
Imagine you are trying to define 20 Buttons in your view. In your declarative layout you would declare each button explicitly, while in your imperative layout you would most likely use a for-loop. It seems likely that this would lead to smaller JS size for the imperative layout.
Also consider that in real world applications, this difference might be negligible, as views usually are the smallest part of a project.
The documentation of UiBinder seems to suggest, that it is more about runtime performance, so if you are interested in decreasing load time I suggest you take a look at
Code Splitting,
HTML5 Appcache
and general performance tips (though a bit outdated, still very useful!)
Thanks for the question, I searched for an extensive performance test suite for GWT features ( like UiBinder ) but came up empty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With