Qml應用性能優(yōu)化ppt課件_第1頁
Qml應用性能優(yōu)化ppt課件_第2頁
Qml應用性能優(yōu)化ppt課件_第3頁
Qml應用性能優(yōu)化ppt課件_第4頁
Qml應用性能優(yōu)化ppt課件_第5頁
已閱讀5頁,還剩18頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、Qml運用性能優(yōu)化;QML的執(zhí)行 QML的編譯 QML的執(zhí)行、實例化 QML的渲染QML的編譯QML的執(zhí)行、實例化QML的顯示setSourceApp.exec;QML的設(shè)計思想 QML運用在啟動時,會對qml進展編譯,并且對一切元素進展實例化 比如顯示一個Button : id.visiable=true QML不是一個傳統(tǒng)的解釋型言語,運轉(zhuǎn)時 將一切代碼編譯 將一切代碼實例化 目的:犧牲啟動性能,保證運用的運轉(zhuǎn)性能 QML的這種設(shè)計,導致了。;QML性能分析ListMyListItem.qmlMyListItem.qmlMyListItem.qmlMyListItem.qmlMyListI

2、tem.qmlMyListItem.qmlMyListItem.qmlTextButtonCMOS_BasicDialogCMOS_BasicDialog運用在啟動的時候,會創(chuàng)建14個CMOS_BasicDialog,每個CMOS_BasicDialog用時20ms,總共破費280ms;qmlprofiler 需求在運用的.pro開啟qml debug:CONFIG += qml_debug 編輯appconfig.xml,修正運用的啟動項 /usr/bin/cmoscalculator -qmljsdebugger=port:3768,block 重啟機器 點擊運轉(zhuǎn)運用 在PC端運轉(zhuǎn)QtCr

3、eator;QML的編譯 一切經(jīng)過import方式引入進來的qml代碼都將會被編譯 一個qml文件只會被編譯一次 Qml文件會被編譯成為特定的字節(jié)碼;控制QML的編譯 將QML文件分到多個不同的QML文件 采用動態(tài)創(chuàng)建QML組件的方式;QML實例化 一切元素在運轉(zhuǎn)前都會被實例化 內(nèi)存占用很高 運用的啟動速度很慢 優(yōu)化戰(zhàn)略:用到的時候才需求實例化 采用Qt.createComponent()的方式,動態(tài)創(chuàng)建qml組件;三種不同的寫法不編譯、不實例化Qt.createComponent(“qrc:/qml/Alarm/AlarmMain.qml)只編譯,不實例化Component Item CMO

4、S_PageStackWindow CMOS_BasicDialog CMOS_LineEdit 編譯且實例化 Tab id :alarm ;異步Loader 本身并不節(jié)省時間 可以添加并行效果 可以在總時間不變的情況下,提高用戶體驗;性能優(yōu)化 Do it faster Do it in parallel Do it later Dont do it at all Do it before;QML的優(yōu)化技巧 Text Element Image Controlling Element Lifetime Render /doc/qt-5/qtquick-perform

5、ance.html;Text Element PlainText StyledText AutoText RichText ;ImagesAsynchronous LoadingImages 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 to true to enable asynchronous loading of images

6、 from the local file system Explicit Source SizeIf 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 memory, rather than the large one.

7、;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 until required. Using the overl

8、oaded version of the setSource() function, initial property values can be supplied. Setting the Loader asynchronous property to true may also improve fluidity while a component is instantiated.;Controlling Element LifetimeUsing Dynamic CreationDevelopers can use the Qt.createComponent() function to

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

10、 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 or sourceComponent property of th

11、e 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.;RenderOver-drawing and Invisible ElementsIf you have elements which are totally covered by ot

12、her (opaque) elements, it is best to set their visible property to false or they will be drawn needlessly.Translucent vs OpaqueOpaque content is generally a lot faster to draw than translucent. The reason being that translucent content needs blending and that the renderer can potentially optimize op

13、aque content better.ShaderWhen 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.;文件管理器的優(yōu)化FileEditBar.qml CMOS_BasicDialog id:deleteConfirmDialog CMOS_BasicDialog id:renameDialog CMOS

14、_BasicDialog id:progressDialog 兩種優(yōu)化方法 動態(tài)創(chuàng)建 Re-use existing components;運用啟動的優(yōu)化 生成Image時,運轉(zhuǎn)prelink 運用Booster機制 進展CPU調(diào)頻 調(diào)整運用的啟動效果 發(fā)布Release版本;Booster的機制mapplauncherBoosterinvokerFork一個進程Preload preload.qml啟動進程命令Booster加載進程重命名進程,繼續(xù)加載對應QML;對Booster的優(yōu)化 優(yōu)化前 CMOS_PageStackWindow CMOS_BasicDialog CMOS_LineEdit CMOS_ListView CMOS_TabView CMOS_Page 優(yōu)化后Item Component Item CMOS_PageStackWindow CMOS_BasicDialog CMOS_LineEdi

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論