Qml应用性能优化.pptx

上传人:za****8 文档编号:14653023 上传时间:2020-07-27 格式:PPTX 页数:23 大小:212.64KB
收藏 版权申诉 举报 下载
Qml应用性能优化.pptx_第1页
第1页 / 共23页
Qml应用性能优化.pptx_第2页
第2页 / 共23页
Qml应用性能优化.pptx_第3页
第3页 / 共23页
资源描述:

《Qml应用性能优化.pptx》由会员分享,可在线阅读,更多相关《Qml应用性能优化.pptx(23页珍藏版)》请在装配图网上搜索。

1、Qml应用性能优化,QML的执行,QML的编译 QML的执行、实例化 QML的渲染,QML的编译,QML的执行、实例化,QML的显示,setSource,App.exec,QML的设计思想,QML应用在启动时,会对qml进行编译,并且对所有元素进行实例化 比如显示一个Button : id.visiable=true QML不是一个传统的解释型语言,运行时 将所有代码编译 将所有代码实例化 目的:牺牲启动性能,保证应用的运行性能 QML的这种设计,导致了。,QML性能分析,List,MyListItem.qml,MyListItem.qml,MyListItem.qml,MyListItem.

2、qml,MyListItem.qml,MyListItem.qml,MyListItem.qml,Text,Button,CMOS_BasicDialog,CMOS_BasicDialog,应用在启动的时候,会创建14个CMOS_BasicDialog ,每个CMOS_BasicDialog用时20ms,总共花费280ms,qmlprofiler,需要在应用的.pro开启qml debug: CONFIG += qml_debug 编辑appconfig.xml,修改应用的启动项 /usr/bin/cmoscalculator -qmljsdebugger=port:3768,block 重启

3、机器 点击运行应用 在PC端运行QtCreator,QML的编译,所有通过import方式引入进来的qml代码都将会被编译 一个qml文件只会被编译一次 Qml文件会被编译成为特定的字节码,控制QML的编译,将QML文件分到多个不同的QML文件 采用动态创建QML组件的方式,QML实例化,所有元素在运行前都会被实例化 内存占用很高 应用的启动速度很慢 优化策略:用到的时候才需要实例化 采用Qt.createComponent()的方式,动态创建qml组件,三种不同的写法,不编译、不实例化 Qt.createComponent(“qrc:/qml/Alarm/AlarmMain.qml”) 只编

4、译,不实例化 Component Item CMOS_PageStackWindow CMOS_BasicDialog CMOS_LineEdit 编译且实例化 Tab id :alarm ,异步Loader,本身并不节省时间 可以增加并行效果 可以在总时间不变的情况下,提高用户体验,性能优化,Do it faster Do it in parallel Do it later Dont do it at all Do it before,QML的优化技巧,Text Element Image Controlling Element Lifetime Render http:/qt-proje

5、ct.org/doc/qt-5/qtquick-performance.html,Text Element,PlainText StyledText AutoText RichText,Images,Asynchronous Loading Images are often quite large, and so it is wise to ensure that loading an image doesnt block the UI thread. Set the asynchronous property of the QML Image element totrueto enable

6、asynchronous loading of images from the local file system Explicit Source Size If your application loads a large image but displays it in a small-sized element, set the sourceSize property to the size of the element being rendered to ensure that the smaller-scaled version of the image is kept in mem

7、ory, rather than the large one.,Controlling Element Lifetime,Lazy Initialization there is no better way to reduce startup time than to avoid doing work you dont need to do, and delaying the work until it is necessary. Using Loader Using the active property of a Loader, initialization can be delayed

8、until required. Using the overloaded version of the setSource() function, initial property values can be supplied. Setting the Loaderasynchronousproperty to true may also improve fluidity while a component is instantiated.,Controlling Element Lifetime,Using Dynamic Creation Developers can use the Qt

9、.createComponent() function to create a component dynamically at runtime from within JavaScript, and then call createObject() to instantiate it. Destroy Unused Elements Elements which are invisible because they are a child of a non-visible element (for example, the second tab in a tab-widget, while

10、the first tab is shown) should be initialized lazily in most cases, and deleted when no longer in use, to avoid the ongoing cost of leaving them active (for example, rendering, animations, property binding evaluation, etc). An item loaded with a Loader element may be released by resetting the source

11、 or sourceComponent property of the Loader, while other items may be explicitly released by calling destroy() on them. In some cases, it may be necessary to leave the item active, in which case it should be made invisible at the very least.,Render,Over-drawing and Invisible Elements If you have elem

12、ents which are totally covered by other (opaque) elements, it is best to set their visible property tofalseor they will be drawn needlessly. Translucent vs Opaque Opaque content is generally a lot faster to draw than translucent. The reason being that translucent content needs blending and that the

13、renderer can potentially optimize opaque content better. Shader When deploying to low-end hardware and the shader is covering a large amount of pixels, one should keep the fragment shader to a few instructions to avoid poor performance.,文件管理器的优化,FileEditBar.qml CMOS_BasicDialog id:deleteConfirmDialo

14、g CMOS_BasicDialog id:renameDialog CMOS_BasicDialog id:progressDialog ,两种优化方法 动态创建 Re-use existing components,应用启动的优化,生成Image时,运行prelink 使用Booster机制 进行CPU调频 调整应用的启动效果 发布Release版本,Booster的机制,mapplauncher,Booster,invoker,Fork一个进程,Preload preload.qml,启动进程,命令Booster加载进程,重命名进程,继续加载对应QML,对Booster的优化,优化前 C

15、MOS_PageStackWindow CMOS_BasicDialog CMOS_LineEdit CMOS_ListView CMOS_TabView CMOS_Page ,优化后 Item Component Item CMOS_PageStackWindow CMOS_BasicDialog CMOS_LineEdit CMOS_ListView CMOS_TabView CMOS_Page ,调整应用启动的效果,为每个应用创建一个splash图片 启动应用的时候,显示启动动画,显示splash图片 启动动画的时长从500ms,减少到300ms 在应用内容刷新后,在将splash与应用内容之间做个淡入淡出的效果,参考文档,http:/qt-project.org/doc/qt-5/qtquick-performance.html Qml Optimization Tips,

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!