Qt/Embedded Performance TuningWhen building embedded applications on low-powered devices, a number of options are available that are not relevant for desktop applications. These options reduce the memory and/or CPU requirements by making various trade-offs. The most direct way of saving resources is to avoid compiling in features that are not required. See The Feature Definition File for details. General Programming StyleThe following guidelines will improve CPU performance:
Static vs. Dynamic LinkingA lot of CPU and memory is used by the ELF linking process. You can make significant savings by using a static build of your application suite. This means that rather than having dynamic Qt libraries and a collection of executables which link dynamically to these libraries, you build all the applications into a single executable and statically link that with static Qt libraries. This improves start-up time, and reduces memory usage, at the expense of flexibility (to add a new application, you must recompile the single executable) and robustness (if one application has a bug, it might harm other applications). If you need to install end-user applications, this may not be an option, but if you are building a single application suite for a device with limited CPU power and memory, this option could be very beneficial. To compile Qt as a static library, use the -static option when you run configure. To build your application suite as an all-in-one application, design each application as a stand-alone widget or set of widgets, with only minimal code in the main() function. Then, write an application that provides a means of switching between the applications (e.g. a QIconView). The Qtopia is an example of this. It can be built either as a set of dynamically linked executables, or as a single static application. Note that you should generally still link dynamically against the standard C library and any other libraries which might be used by other applications on your device. Alternative Memory AllocationWe have found that the libraries shipped with some C++ compilers on some platforms have poor performance in the built-in "new" and "delete" operators. You might gain performance by re-implementing these functions. For example, you can switch to the plain C allocators by adding the following to your code: void *operator new[](size_t size) { return malloc(size); } void *operator new(size_t size) { return malloc(size); } void operator delete[](void *ptr) { free(ptr); } void operator delete[](void *ptr, size_t) { free(ptr); } void operator delete(void *ptr) { free(ptr); } void operator delete(void *ptr, size_t) { free(ptr); } |
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Developer Network au hasardLa création de colonnes dans une ListView en QMLLe Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.0 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com