How to make efficient apps?
Hello!
I'm writing apps for embedded using QT 4.5.1 and I was wondering are there any rules or something of making apps? I'm asking because my apps are taking a lot of system resources. For example one app take almost the same amount of resources as all Qtopia. How should I compile them? Now I'm compiling as 'Release' but it's not much better then 'Debug'. Any suggestions?
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
There is no simple answer to this question. It all depends on what your application does and how it works. As a first step you might strip some functionality from Qt/Qtopia. A second step would be to better manage your app's resources by allocating less memory and freeing up memory as soon as you don't need it anymore. You can also tweak optimization settings of your compiler (i.e. optimize for size instead of speed).
Re: How to make efficient apps?
What about using older version of QT? Would apps be faster and take less resources? Or maybe version is irrelevant?
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
It depends how much older. In general Qt tends to be getting faster and more optimized. In general it's best to strip out features you don't need - performance will improve then too. But if you are thinking about getting a single download that will make your app twice as fast - it's not that simple. If you want improvements, you have to dedicate your own time to make (1) improvements to your code and only then (2) optimized builds of Qt.
Re: How to make efficient apps?
Quote:
Originally Posted by
Tomasz
What about using older version of QT? Would apps be faster and take less resources? Or maybe version is irrelevant?
If you stick to the 4.x series, you should never downgrade for performance. The Trolls spend lots of time improving performance and actually have regressions for performance, to ensure that they do not reduce performance in any area of the library while working on new features. I'd rather recommend an upgrade if you're after performance.
Then comes the question - what type of performance are you looking for? Graphics? SQL? Networking? Handling of QByteArrays?
Re: How to make efficient apps?
Quote:
Originally Posted by
e8johan
Then comes the question - what type of performance are you looking for? Graphics? SQL? Networking? Handling of QByteArrays?
Graphics and SQL are important for me. I won't downgrade version of my QT I think You're right. For now I've compiled my libs again disablig some options and setting optimization (-O1). Options I've used:
Code:
-embedded arm -xplatform qws/linux-arm-g++ -prefix -qt-mouse-tslib -little-endian -no-dbus -no-phonon -no-phonon-backend -no-mmx -no-3dnow -no-sse -no-sse2 -no-webkit -no-qt3support -no-cups -no-largefile -optimized-qmake -no-openssl -nomake tools -nomake examples -nomake demos -release
Is there anything more I can do about optimization? I've found some options but I don't know what are that options for: stl, nis, sm, xshape, xinerama, xfixes, xrandr, xrender, tablet, xkb, separate-debug-info.
And one more thing - in every tutorial about compiling QT libs optimization is set to -O0, is it safe to set it to -O2?
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
That's not enough. Build a program called qconfig (it's in tools directory of the Qt source distribution) and run it. It will let you tweak some defines that will prevent building some parts of the libraries (i.e. drag&drop support, particular widgets you don't use, etc.).
Re: How to make efficient apps?
Thanks Wysota! Two more questions about that application - I've opened text file 'qfeatures.txt', disabled some features I won't use, and what now? When I want to save that file program asks me to choose header file. Should it be 'qglobal.h'? Should I change features in this app after or before making './configure [...]'?
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
Save it as src/corelib/global/qfeatures.h, run configure, make, etc.
Re: How to make efficient apps?
I've tried to change something with that app, but I get always the same error during compilation:
Code:
../../corelib/codecs/qtextcodec.cpp
../../corelib/codecs/qtextcodec.cpp:98: error: expected initializer before ‘*’ token
..
/..
/corelib
/codecs
/qtextcodec.
cpp: In function ‘
QTextCodec* createForName
(const QByteArray
&)’
:../../corelib/codecs/qtextcodec.cpp:137: error: ‘QFactoryLoader’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:137: error: ‘l’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:137: error: ‘loader’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:142: error: ‘QTextCodecFactoryInterface’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:142: error: ‘factory’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:143: error: ‘qobject_cast’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:143: error: expected primary-expression before ‘>’ token
..
/..
/corelib
/codecs
/qtextcodec.
cpp: In function ‘
QTextCodec* createForMib
(int)’
:../../corelib/codecs/qtextcodec.cpp:158: error: ‘QTextCodecFactoryInterface’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:158: error: ‘factory’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:159: error: ‘qobject_cast’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:159: error: expected primary-expression before ‘>’ token
../../corelib/codecs/qtextcodec.cpp:159: error: ‘loader’ was not declared in this scope
..
/..
/corelib
/codecs
/qtextcodec.
cpp: In
static member function ‘
static QList<QByteArray>
QTextCodec::availableCodecs()’
:../../corelib/codecs/qtextcodec.cpp:1000: error: ‘QFactoryLoader’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:1000: error: ‘l’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:1000: error: ‘loader’ was not declared in this scope
..
/..
/corelib
/codecs
/qtextcodec.
cpp: In
static member function ‘
static QList<int>
QTextCodec::availableMibs()’
:../../corelib/codecs/qtextcodec.cpp:1028: error: ‘QFactoryLoader’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:1028: error: ‘l’ was not declared in this scope
../../corelib/codecs/qtextcodec.cpp:1028: error: ‘loader’ was not declared in this scope
even if I change only one thing. Maybe I'm doing something wrong?
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
What exactly did you change? Could you compress and post your header file created by qconfig?
Re: How to make efficient apps?
I've changed only drag&drop option. Header file created by qconfig looks like this:
Code:
/* Kernel */
#ifndef QT_NO_DRAGANDDROP
# define QT_NO_DRAGANDDROP
#endif
And nothing more.
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
And what exactly did you do afterwards? Did you clean the source tree prior to running configure and make?
Re: How to make efficient apps?
Quote:
Originally Posted by
wysota
And what exactly did you do afterwards? Did you clean the source tree prior to running configure and make?
Afterwards I've run 'configure' and then 'make'. What about 'clean source tree prior'? Why and how should I do it?
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
Quote:
Originally Posted by
Tomasz
Why and how should I do it?
"make distclean". You should run it to be sure there are no stale files remaining from the previous compilation.
By the way, which version of Qt are you trying to build?
Re: How to make efficient apps?
Quote:
Originally Posted by
wysota
"make distclean". You should run it to be sure there are no stale files remaining from the previous compilation.
By the way, which version of Qt are you trying to build?
4.5.1 - I've built it earlier but in 'simple' version (without qconfig configuration) and it works, but I want to make it as fast as I can by disabling all unecessary things.
I'll try what You said. Thanks for help!
best regards
Tomasz
Re: How to make efficient apps?
Why not build 4.6.3? 4.6 branch has introduced many optimizations to some areas of Qt.
Re: How to make efficient apps?
Earlier I had some problems with building 4.6.x version. But now I think I can handle that problems and try to build it - You've convinced me! :)
best regards
Tomasz
Re: How to make efficient apps?
Quote:
Originally Posted by
wysota
"make distclean". You should run it to be sure there are no stale files remaining from the previous compilation.
I've done it and have the same problem. Nothing changed.
thanks in advance
best regards
Tomasz
Re: How to make efficient apps?
What is the offending line? What platform are you building for?