Engineering

ConstraintLayout 1.1.2 performance test

ConstraintLayout v1.1.2 performance test

Speculations about ContraintLayout have been coming back all the time since it saw the light of the day. The view group, praised by creators (Google), which quickly gained a lot of interest among software developers is described as "working one" and one of the most efficient layouts. But is it true?

Inspired by Piotr Krystyniak's article ContraintLayout performance{:target="_blank"}, I've faced the same performance test for the newest version of ConstraintLayout. I have decided to use a new feature, which basically allows to set percent values relative to screen dimensions for width and height of the view. The equivalent of this for LinearLayout would be layout weights.

Preparation for the test

Layouts:

Device:

  • Nexus 5X
  • Android 8.1.0

Way of testing

  • I've used the same test as Piotr{:target="_blank"} in his article, which is available here{:target="_blank"}

Assumptions

  • The result is an average for 1000 iterations of following steps: inflate, measure and layout for each case

Visual presentation of layout:

layout

Results

results

Results are quite surprising! Average time for single sequence of inflate, measure and layout for LinearLayouts took ~6 ms and for ConstraintLayout ~10 ms. Unfortunately, ConstraintLayout almost doubled LinearLayouts time needed to process the entire view. It might be caused by the new percentage feature used in my implementation. This means Google has a lot of work to do in order to make this layout's fame no longer be ahead of the layout itself.