Skip to content

30% Faster Startup Thanks to QtQuick Compiler

Update: Since Qt 5.12, the QtQuick compiler has been available under LGPLv3. Even if you don’t have a commercial Qt license, you will be able to enjoy a significantly faster startup of embedded QML applications.

It is not easy to find hard data about how much the QtQuick compiler can speed up the startup of real-life application. As I had some time on my hands this weekend, I measured the startup times of the HMI of a maize harvester running on a quad-core NXP/Freescale i.MX6 (Nit6Q_W_BCOM). Using the QtQuick compiler from Qt 5.7 brings the startup time from 2.72s down to 1.91s – a speedup of 30%!

I measured the time from starting the application to showing the home screen, which is the point when the user can start interacting with the HMI. As you can see from the screenshot, the home screen is a pretty complex QML screen and hence a good optimisation target for the QtQuick compiler. The QML code of the home screen wasn’t optimised for faster startup at all.

Home screen in field and day mode

Home screen of maize harvester

I connected the frameSwapped() signal of the HMI’s QQuickView with the quit() slot of QCoreApplication. This signal is emitted whenever the rendering engine flips the back and front framebuffer, that is, when the back buffer becomes visible. The very first emission of frameSwapped() after startup makes the Home screen visible. Connecting this signal with exiting the application allowed me to use the Linux command time to measure the startup time. The HMI application is terminated at exactly the point where the user could start interacting with it.

Without the QtQuick compiler, the startup takes 2.72 seconds (the sum of user and system time). With the QtQuick compiler, the startup takes only 1.91 seconds. The QtQuick compiler speeds up the startup of the harvester HMI by 0.81 seconds or 30%. I only had to add CONFIG+=qtquickcompiler to the qmake call and rebuild my application. This is very little effort for a 30% speedup!

4 thoughts on “30% Faster Startup Thanks to QtQuick Compiler”

    1. Burkhard Stubert

      The post “Building with CMake” describes how to add the QtQuick compiler in a CMake build. Essentially, you need to add the following two statements to your CMake files:

      qtquick_compiler_add_resources(RESOURCES example.qrc)

      The second statement replaces the normal qt5_add_resources() function.

  1. This was with the compile-time QML compiler in the commercial version of Qt, correct? I’d be curious to see what the results would be with the new run-time compiler/JIT caching feature that is in Qt 5.8.0 beta.

    1. Burkhard Stubert

      Yes, it was the compile-time QML compiler from the commercial Qt version.

      Trying it out with the run-time comiler and JIT caching feature of Qt 5.8 is a good idea. It’s on my todo-list.

Leave a Reply

Your email address will not be published. Required fields are marked *