Advanced Techniques
高级技能
Performance of QML
QML的性能
QML and Javascript are interpreted languages. This means that they do not have to be processed by a compiler before being executed. Instead, they are being run inside an execution engine. However, as interpretation is a costly operation, various techniques are used to improve performance.
QML和Javascript是解释型语言。这意味着它们在执行之前不必经过编译器的处理。相反,它们是在执行引擎中运行的。然而,由于解释是一项成本高昂的操作,因此使用了各种技术来提高性能。
The QML engine uses just-in-time (JIT) compilation to improve performance. It also caches the intermediate output to avoid having to recompile. This works seamlessly for you as a developer. The only trace of this is that files ending with qmlc
and jsc
can be found next to the source files.
QML引擎使用实时(JIT)编译来提高性能。它还缓存中间输出,以避免重新编译。这对作为开发人员的您来说是隐藏的。唯一的线索是,可以在源文件旁边找到以qmlc和jsc结尾的源文件。
If you want to avoid the initial start-up penalty induced by the initial parsing you can also pre-compile your QML and Javascript. This requires you to put your code into a Qt resource file, and is described in detail in the Compiling QML Ahead of Time chapter in the Qt documentation.
如果希望避免初始解析导致的初始启动延时,还可以预编译QML和Javascript。这要求您将代码放入Qt资源文件中,Qt文档中的提前编译QML一章对此进行了详细描述。