SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Performance Tips & Tricks for Qt-QML Apps
               Rajesh Lal, Nokia
High Performance QML Applications


                         +                      =
      Qt Quick                    QML               MeeGo Apps
    Qt UI Creation Kit       Most Advanced UI       High Performance


2
Agenda


               QML
    Qt Quick         7 Tips   Tools
               App




3
What is Qt Quick
                   • QML
                   • IDE – Qt Creator
                   • Qt UI Designer
                   • Plugin for Mobility API
                   • Quick Components

     The Fastest way to develop for MeeGo

4
What is QML
                    • Qt Meta-Object Language
                    • JavaScript based
                    • Qt Declarative runtime
                    • CSS-JavaScript like syntax

    The Most Advanced UI technology for Mobile


5
QML

         Powerful
      Declarative
    User Interface
         language



6
QML Elements
    Graphics   Animation      Binding

     Items       State       Property
    Shapes     Transitions   JavaScript
      Text     Transform.       C++


7
What is a Qt QML App


                                      Logic in
                                      JavaScript or
                        UI in QML     C++ API calls
                        (main.qml)
       A Qt
       Container
       (main.cpp)

                    Qt Quick Application
8
Qt-QML App
                            QML App. Viewer
                                                  Property Bind
      1+ QML Files                                JavaScript
    Import libraries
                                          Logic
                                                  C++ Binding
     Import JS files
                             UI
                        1   | 2 | 3


                       Qt Container(main.cpp)
9
What is Performance

     •   Short response time
     •   High Throughput
     •   Low utilization of resources
     •   High availability
     •   High Speed
     •   Instant
     •   Smoothness

10
7 Tips for
     High Performance QML Application




11
Tip 1
     Divide and Rule




12
1: Divide and Rule

     •   Divide application UI into multiple QML files
     •   Each Logical entity as a separate QML file
     •   Think Object Oriented Programming
     •   Do not use 1 Large QML file




13
1: Divide and Rule

     Rule
     • Use main.qml as the main UI
        ₋ With different States & Transitions
        ₋ Create Multiple Views .QML files
        ₋ Import folders containing other QML files
        ₋ Local instances of imported QML elements



14
1: Divide and Rule




15
Tip 2
     Load and Unload




16
2: Load and Unload

     •   Use Loader to control the memory usage
     •   Load the absolute Minimum at the startup
     •   Dynamically Load and Unload UI Components
     •   Create Components when required




17
2: Load and Unload




18
Tip 3
     Use Asynchronous Threads




19
3: Asynchronous Threads

     •   Use WorkerScripts for Remote API Calls
     •   Use Threads for time consuming operations
     •   Load large images asynchronously
     •   Use caching for remote data/image
         (cacheBuffer in listview/Gridview)




20
3: Asynchronous Threads

Login call in MyApp.QML    MyAppScript/Login.QML file




 21
3: Asynchronous Threads

Js/dologin.js




22
Tip 4
        Optimize for Images
     (Greatest User of Memory)




23
4: Optimize for Images

     •   Optimize Images to reduce memory footprints
     •   Specify exact size of the image
     •   Avoid resizing/scaling an image in QML
     •   Lazy load large images (asynchronous=true)
     •   Don’t cache large images (cache=false)
     •   Smooth filter = better visual quality, but slower



24
Tip 5
     Beware of String Operations




25
5: Beware of String Operations

     •   Strings are immutable
     •   multiple '+' operator = multiple memory allocations
     •   Use StringBuilder for more efficient strings
     •   Define
         ₋ #define QT_USE_FAST_CONCATENATION
         ₋ #define QT_USE_FAST_OPERATOR_PLUS



26
Tip 6
     Know States, Transitions, & Animations




27
6: Know States, Transitions, & Animations

     •   In transition, animated area should be small
     •   Animate different items sequentially when possible
     •   Avoid multiple timers during animation
     •   Avoid JavaScript operations during animation
     •   Use ScriptAction & StateChangeScript




28
Tip 7
     Follow Best Practices




29
7: Best Practices

     •   For best performance use C++ instead of JavaScript
     •   Insert properties at top of element declarations
     •   Create application logic outside QML
     •   Don’t build multiple layer of QML hierarchies
     •   Use Qt's i18n for internationalisation & localisation




30
Tools
     QML Performance Monitor
     http://www.youtube.com/watch?v=XdI9C53uJw8

     Valgrind
     http://valgrind.org/docs/manual/mc-manual.html

     QML Performance Guidelines
     http://doc.qt.nokia.com/4.7/qdeclarativeperformance.html




31
Thank You
 @rajeshlalnokia

Weitere ähnliche Inhalte

Mehr von Raj Lal

Workshop Stanford University - 28th July 2018 on Website Optimization
Workshop Stanford University - 28th July 2018 on Website Optimization  Workshop Stanford University - 28th July 2018 on Website Optimization
Workshop Stanford University - 28th July 2018 on Website Optimization
Raj Lal
 

Mehr von Raj Lal (20)

Workshop Stanford University - 28th July 2018 on Website Optimization
Workshop Stanford University - 28th July 2018 on Website Optimization  Workshop Stanford University - 28th July 2018 on Website Optimization
Workshop Stanford University - 28th July 2018 on Website Optimization
 
The art and science of website optimization
The art and science of website optimizationThe art and science of website optimization
The art and science of website optimization
 
UX Workshop - Talent 2 Talent Conference, Ryerson University, Toronto Canada,...
UX Workshop - Talent 2 Talent Conference, Ryerson University, Toronto Canada,...UX Workshop - Talent 2 Talent Conference, Ryerson University, Toronto Canada,...
UX Workshop - Talent 2 Talent Conference, Ryerson University, Toronto Canada,...
 
Why Toastmasters - The story of a fisherman
Why Toastmasters - The story of a fishermanWhy Toastmasters - The story of a fisherman
Why Toastmasters - The story of a fisherman
 
Build Amazing Camera Apps for Superphones - Silicon Valley Code Camp, 6 Oct, ...
Build Amazing Camera Apps for Superphones - Silicon Valley Code Camp, 6 Oct, ...Build Amazing Camera Apps for Superphones - Silicon Valley Code Camp, 6 Oct, ...
Build Amazing Camera Apps for Superphones - Silicon Valley Code Camp, 6 Oct, ...
 
Evolution of User Interface - Digital Web & Design Innovation Summit SFO 20 S...
Evolution of User Interface - Digital Web & Design Innovation Summit SFO 20 S...Evolution of User Interface - Digital Web & Design Innovation Summit SFO 20 S...
Evolution of User Interface - Digital Web & Design Innovation Summit SFO 20 S...
 
Designing Killer Apps for Mobile Devices ModevUX May 9 2013 mclean VA - @iRajLal
Designing Killer Apps for Mobile Devices ModevUX May 9 2013 mclean VA - @iRajLalDesigning Killer Apps for Mobile Devices ModevUX May 9 2013 mclean VA - @iRajLal
Designing Killer Apps for Mobile Devices ModevUX May 9 2013 mclean VA - @iRajLal
 
Html5 Whats around the bend
Html5 Whats around the bendHtml5 Whats around the bend
Html5 Whats around the bend
 
Accessible design with html5 JS Everywhere 2012 Oct 26 Fairmont Hotel San Jos...
Accessible design with html5 JS Everywhere 2012 Oct 26 Fairmont Hotel San Jos...Accessible design with html5 JS Everywhere 2012 Oct 26 Fairmont Hotel San Jos...
Accessible design with html5 JS Everywhere 2012 Oct 26 Fairmont Hotel San Jos...
 
Accessibility on Windows Phone - Windows Phone Meetup at Nokia - 16 October @...
Accessibility on Windows Phone - Windows Phone Meetup at Nokia - 16 October @...Accessibility on Windows Phone - Windows Phone Meetup at Nokia - 16 October @...
Accessibility on Windows Phone - Windows Phone Meetup at Nokia - 16 October @...
 
Accessible design - HOW Interactive Design Conference Washington DC SEPT 27-2...
Accessible design - HOW Interactive Design Conference Washington DC SEPT 27-2...Accessible design - HOW Interactive Design Conference Washington DC SEPT 27-2...
Accessible design - HOW Interactive Design Conference Washington DC SEPT 27-2...
 
Accessible Design with HTML5 - HTML5DevConf.com May 21st San Francisco, 2012 ...
Accessible Design with HTML5 - HTML5DevConf.com May 21st San Francisco, 2012 ...Accessible Design with HTML5 - HTML5DevConf.com May 21st San Francisco, 2012 ...
Accessible Design with HTML5 - HTML5DevConf.com May 21st San Francisco, 2012 ...
 
Developing Apps for Nokia Windows Phone VSLiv Conference May 15, 2012 @iRajLal
Developing Apps for Nokia Windows Phone  VSLiv Conference May 15, 2012 @iRajLalDeveloping Apps for Nokia Windows Phone  VSLiv Conference May 15, 2012 @iRajLal
Developing Apps for Nokia Windows Phone VSLiv Conference May 15, 2012 @iRajLal
 
Upgrade Your Website to HTML5 - VSLive Conference New York @iRajLal
Upgrade Your Website to HTML5 - VSLive Conference New York  @iRajLalUpgrade Your Website to HTML5 - VSLive Conference New York  @iRajLal
Upgrade Your Website to HTML5 - VSLive Conference New York @iRajLal
 
Fun with silverlight4 Table of Content @iRajLal
Fun with silverlight4 Table of Content @iRajLalFun with silverlight4 Table of Content @iRajLal
Fun with silverlight4 Table of Content @iRajLal
 
Honeycomb User Interface Design @iRajLal
Honeycomb User Interface Design @iRajLalHoneycomb User Interface Design @iRajLal
Honeycomb User Interface Design @iRajLal
 
Two thumbs User Interface @iRajLal
Two thumbs User Interface @iRajLalTwo thumbs User Interface @iRajLal
Two thumbs User Interface @iRajLal
 
Angry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLal
Angry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLalAngry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLal
Angry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLal
 
Fun with QML and JavaScript: Embedded Linux Conference 11th April 2011, Hotel...
Fun with QML and JavaScript: Embedded Linux Conference 11th April 2011, Hotel...Fun with QML and JavaScript: Embedded Linux Conference 11th April 2011, Hotel...
Fun with QML and JavaScript: Embedded Linux Conference 11th April 2011, Hotel...
 
Build Cutting edge Mobile Apps using QML and JavaScript for MeeGo N9: Linux F...
Build Cutting edge Mobile Apps using QML and JavaScript for MeeGo N9: Linux F...Build Cutting edge Mobile Apps using QML and JavaScript for MeeGo N9: Linux F...
Build Cutting edge Mobile Apps using QML and JavaScript for MeeGo N9: Linux F...
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Performance Tips & Tricks for QT/QML Apps: MeeGo Conference San Francisco, Hyatt Regency, May 23-25,2011 @iRajLal

  • 1. Performance Tips & Tricks for Qt-QML Apps Rajesh Lal, Nokia
  • 2. High Performance QML Applications + = Qt Quick QML MeeGo Apps Qt UI Creation Kit Most Advanced UI High Performance 2
  • 3. Agenda QML Qt Quick 7 Tips Tools App 3
  • 4. What is Qt Quick • QML • IDE – Qt Creator • Qt UI Designer • Plugin for Mobility API • Quick Components The Fastest way to develop for MeeGo 4
  • 5. What is QML • Qt Meta-Object Language • JavaScript based • Qt Declarative runtime • CSS-JavaScript like syntax The Most Advanced UI technology for Mobile 5
  • 6. QML Powerful Declarative User Interface language 6
  • 7. QML Elements Graphics Animation Binding Items State Property Shapes Transitions JavaScript Text Transform. C++ 7
  • 8. What is a Qt QML App Logic in JavaScript or UI in QML C++ API calls (main.qml) A Qt Container (main.cpp) Qt Quick Application 8
  • 9. Qt-QML App QML App. Viewer Property Bind 1+ QML Files JavaScript Import libraries Logic C++ Binding Import JS files UI 1 | 2 | 3 Qt Container(main.cpp) 9
  • 10. What is Performance • Short response time • High Throughput • Low utilization of resources • High availability • High Speed • Instant • Smoothness 10
  • 11. 7 Tips for High Performance QML Application 11
  • 12. Tip 1 Divide and Rule 12
  • 13. 1: Divide and Rule • Divide application UI into multiple QML files • Each Logical entity as a separate QML file • Think Object Oriented Programming • Do not use 1 Large QML file 13
  • 14. 1: Divide and Rule Rule • Use main.qml as the main UI ₋ With different States & Transitions ₋ Create Multiple Views .QML files ₋ Import folders containing other QML files ₋ Local instances of imported QML elements 14
  • 15. 1: Divide and Rule 15
  • 16. Tip 2 Load and Unload 16
  • 17. 2: Load and Unload • Use Loader to control the memory usage • Load the absolute Minimum at the startup • Dynamically Load and Unload UI Components • Create Components when required 17
  • 18. 2: Load and Unload 18
  • 19. Tip 3 Use Asynchronous Threads 19
  • 20. 3: Asynchronous Threads • Use WorkerScripts for Remote API Calls • Use Threads for time consuming operations • Load large images asynchronously • Use caching for remote data/image (cacheBuffer in listview/Gridview) 20
  • 21. 3: Asynchronous Threads Login call in MyApp.QML MyAppScript/Login.QML file 21
  • 23. Tip 4 Optimize for Images (Greatest User of Memory) 23
  • 24. 4: Optimize for Images • Optimize Images to reduce memory footprints • Specify exact size of the image • Avoid resizing/scaling an image in QML • Lazy load large images (asynchronous=true) • Don’t cache large images (cache=false) • Smooth filter = better visual quality, but slower 24
  • 25. Tip 5 Beware of String Operations 25
  • 26. 5: Beware of String Operations • Strings are immutable • multiple '+' operator = multiple memory allocations • Use StringBuilder for more efficient strings • Define ₋ #define QT_USE_FAST_CONCATENATION ₋ #define QT_USE_FAST_OPERATOR_PLUS 26
  • 27. Tip 6 Know States, Transitions, & Animations 27
  • 28. 6: Know States, Transitions, & Animations • In transition, animated area should be small • Animate different items sequentially when possible • Avoid multiple timers during animation • Avoid JavaScript operations during animation • Use ScriptAction & StateChangeScript 28
  • 29. Tip 7 Follow Best Practices 29
  • 30. 7: Best Practices • For best performance use C++ instead of JavaScript • Insert properties at top of element declarations • Create application logic outside QML • Don’t build multiple layer of QML hierarchies • Use Qt's i18n for internationalisation & localisation 30
  • 31. Tools QML Performance Monitor http://www.youtube.com/watch?v=XdI9C53uJw8 Valgrind http://valgrind.org/docs/manual/mc-manual.html QML Performance Guidelines http://doc.qt.nokia.com/4.7/qdeclarativeperformance.html 31