source: trunk/doc/html/emb-performance.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 5.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qws.doc:532 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Qt/Embedded Performance Tuning</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Qt/Embedded Performance Tuning</h1>
33
34
35When building embedded applications on low-powered devices, a number
36of options are available that would not be considered in a desktop
37application environment. These options reduce the memory and/or CPU
38requirements at the cost of other factors.
39<p> <ul>
40<li> <a href="emb-features.html"><b>Tuning the functionality of Qt</a>
41<li> <a href="#general">General programming style</a>
42<li> <a href="#static">Static vs. Dynamic linking</a>
43<li> <a href="#alloc">Alternative memory allocation</a>
44</ul>
45<p> <a name="general"></a>
46<h2> General programming style
47</h2>
48<a name="1"></a><p> The following guidelines will improve CPU performance:
49<ul>
50<li> Create dialogs and widgets once, then <a href="qwidget.html#hide">QWidget::hide</a>() and
51<a href="qwidget.html#show">QWidget::show</a>() them, rather than creating them and deleting
52them every time they are needed.
53This will use a little more memory, but will be much faster.
54Try to create them the first time "lazily" to avoid slow
55startup (e.g. only create a Find dialog the first time the
56user invokes it).
57</ul>
58<p> <a name="static"></a>
59<h2> Static vs. Dynamic linking
60</h2>
61<a name="2"></a><p> A lot of CPU and memory is used by the ELF linking process. You can
62make significant savings by using a static build of your application
63suite. This means that rather than having a dynamic library (<tt>libqte.so</tt>) and a collection of executables which link dynamically to
64that library, you build all the applications into a single executable
65and statically link that with a static library (<tt>libqt.a</tt>). This
66improves start-up time, and reduces memory usage, at the expense of
67flexibility (to add a new application, you must recompile the single
68executable) and robustness (if one application has a bug, it might
69harm other applications). If you need to install end-user
70applications, this may not be an option, but if you are building a
71single application suite for a device with limited CPU power and
72memory, this option could be very beneficial.
73<p> To compile Qt as a static library, add the <tt>-static</tt> options when
74you run configure.
75<p> To build your application suite as an all-in-one application, design each
76application as a stand-alone widget or set of widgets, with only minimal
77code in the main() function. Then, write an application that gives
78some way to switch between the applications (e.g. a <a href="qiconview.html">QIconView</a>).
79<a href="http://www.trolltech.com/products/qtopia/index.html">Qtopia</a> is an example of this. It can be built either as a set of
80dynamically linked executables, or as a single static application.
81<p> Note that you should generally still link dynamically against the
82standard C library and any other libraries which might be used by
83other applications on your device.
84<p> <a name="alloc"></a>
85<h2> Alternative memory allocation
86</h2>
87<a name="3"></a><p> We have found that the libraries shipped with some C++ compilers on
88some platforms have poor performance in the built-in "new" and "delete"
89operators. You might gain performance by re-implementing these
90functions. For example, you can switch to the plain C allocators
91by adding the following to your code:
92<p> <pre>
93 void* operator new[]( size_t size )
94 {
95 return malloc( size );
96 }
97
98 void* operator new( size_t size )
99 {
100 return malloc( size );
101 }
102
103 void operator delete[]( void *p )
104 {
105 free( p );
106 }
107
108 void operator delete[]( void *p, size_t size )
109 {
110 free( p );
111 }
112
113 void operator delete( void *p )
114 {
115 free( p );
116 }
117
118 void operator delete( void *p, size_t size )
119 {
120 free( p );
121 }
122</pre>
123
124
125<!-- eof -->
126<p><address><hr><div align=center>
127<table width=100% cellspacing=0 border=0><tr>
128<td>Copyright &copy; 2007
129<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
130<td align=right><div align=right>Qt 3.3.8</div>
131</table></div></address></body>
132</html>
Note: See TracBrowser for help on using the repository browser.