So, why is Human slow?

A Man And A WomanI mentioned a while back that Human is the slowest of all common themes, taking 6ms to draw the average frame.  It occurred to me to wonder why this might be, of course, so I took the opportunity to instrument it.  Here are the results.  The height of the diagram spans six milliseconds.  You will note firstly that the theme carries out a large number of very simple operations like lines and rectangles, which are very fast, and next that there are four long pauses which I have numbered in red:

  1. Drawing a gradient.  This is the first gradient in title_background, covering the entire width of the titlebar and half its height. There are three other gradient operations, and none of them take that long; this could be some caching mechanism in GDK but is more likely to be because at least one of them is only a single pixel high.  The other two are a bit of a mystery; the output says they should be part of piece 11, bottom_edge, but that isn’t used in Human.
  2. Drawing a tint.  Again, it’s the first one in corners_hilight_shaded, so maybe some caching effect, but this is also the only tint which is 1×2 pixels high instead of just 1×1; there is one tint which is 2×1, and this is visible taking longer slightly below the number 2.
  3. Drawing the title text.  This happens four times, and two are very fast and one is very slow.  I can’t account for this.
  4. Drawing the title text again; see above.

I think this shows that gradients and tints need to be faster.

(Update follows >>>)

Photo © just.Luc, cc-by-nc-sa.