本页内容

QML Profiler 应用程序性能分析

QML Profiler

借助 QML Profiler ,您可以分析 QML 代码中的性能问题。该分析器是Qt Creator 和Qt Design Studio 的组成部分。最佳使用方式是采用Qt Creator 或Qt Design Studio 中的默认构建和运行设置。

Qt Extension for Visual Studio Code 还包含一个 QML Profiler。

如果您是手动构建或运行,为了使用QML Profiler ,您需要启用QML 调试基础设施。

使用命令行 qmlprofiler 工具

Qt 提供了qmlprofiler命令行工具,用于将性能分析数据捕获到文件中。该文件随后可加载到Qt Creator 或Qt Design Studio 中进行分析。它通过调试协议连接到应用程序。

要运行此工具,请在启用QML 调试基础设施后启动应用程序,然后输入以下命令:

qmlprofiler -p <port> -attach <ip address>

建议在-qmljsdebugger 中使用services 参数,以将调试基础设施限制为仅包含所需的服务。这些服务通常包括CanvasFrameRate 、EngineControl 和DebugMessages 。启用其他服务可能会影响性能分析结果。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.