| Performance Tuning of Code |
|
|
|
Performance Tuning of Code
If an application runs and performs all required task for the user or client, doesn’t means that it is complete in all the sense. Using performance analysis tools like profiler we can find out how our application is performing internally means in terms of speed, memory usage and power utilization. There are lots of issues which can reduce performance of your application; below I am listing some of them Issue 1: Dll Usage Optimization:
void RuntimeLoadDllL()
{
RFs fileSession;
User::LeaveIfError(fileSession.Connect());
TFileName dllName;
If ( SomeCondition )
{
.......
dllName = KDllNameOne;
}
else
{
.........
dllName = KDllNameTwo;
}
LoadDllL(dllName);
.....................
fileSession.Close();
}
void LoadDllL(const TFileName& aLibName)
{
RLibrary lib;
User::LeaveIfErrorlib.Load(aLibName));
.....
}
ECOM also provide a standard mechanism to load specific implementation at run time. Issue 2: Check usage of TRAPs:
Issue 3: Check Server Usage and Optimization
If the server is rarely used, this approach can be seen as ineffective resource utilization. On-demand connection to transient is always advisable. Design should be in such a way that client API implementation should be kept separate from the actual server implementation in this way when the client links to the client API library, it will not load server dependencies automatically which should be happen after the server is really started. While designing server always think about its usage and the various resources it needs at runtime. Suppose server provide three features like Read, Write and Notification and read/rite is not very frequent operation in such scenario its better to breakup into two servers one which will provide heavyweight functionality like read/rite/replace etc.. This will be loaded/unloaded depending upon client requirements and other into always up light weighted notified server. Issue 4: Compressing the executable:
It allows the stored executables to use less space on the file system. The executable loader decompressed the file when it is loaded. All executable should not be decompressed, only those who can take large amount of space are candidate for that. Issue 5: File Scanning:
Issue 6: Check Memory Usage Optimizations:
Issue 7: Check usage of default parameters
void MyFunction( TInt aCounterVal, TInt aParamLength = 2); Can be written as : void MyFunction( TInt aCounterVa ); void MyFunction( TInt aCounterVal, TInt aParamLength ); Issue 8: Check Usage of Reference and Pointer:
Issue 9: Check for inline keyword and Initialization list
There are some more issues related to inline methods like change in the implementation can break binary compatibility and if you have issues like limited memory resource than speed cost of a method call is preferable to the large body of inline code. Using initialization list for constructors is more efficient than assignment within the constructor body because class member variables are automatically constructed using there default constructor prior to entry within the class constructor itself. However the constructor lists does not allow us to validation of variables and hence they are not always suitable. Issue 10: Check disk space issue:
You can get volume information comprising all the information provided by DriveInfo, which additionally gives the volume name, its ID, its size and the amount of free space. Use RFs::Volume() to get a TVolumeInfo object TVolumeInfo volumeInfo;
....................
TInt err=ifsSession.Volume(volumeInfo, EDriveZ);
if (err != KErrNone)
{
........................
User::LeaveIfError(fsSession.DriveToChar(EDriveZ,driveLetter);
......................
}
Issue 11: Check usage of Descriptors:
Avoid creation of multiple local instances of class objects like TFileName, TParse etc.., better to have a member variable. Avoid usage of _L literal macros because of extra runtime overhead associated with construction of temporary descriptor which is the why they are deprecated in production code. Issue 12: Check usage of Arrays:
CArray classes re-use the CBufBase framework to provide two alternative storage structures for the array data with very little CArray specific code. There are two assertions for every array access, one in the CArray code and one in the CBufBase code plus a number of TRAP harnesses are used to catch allocation failure. In addition, the CBufBase code operates in terms of byte buffers, and these appear in the API as descriptors. In the implementation, this requires a TPtr8 to be constructed, returned and inspected for every array access. This means that, although very powerful, the implementation of the CArray classes can add considerable overhead for simple vector-like flat arrays of fixed length objects. Don’t feel that CArray is so bad because the main benefit from the CArray classes is their support for segmented storage and their ability to handle arrays of variable length objects. However, the latter is a rare requirement. and RArray stores objects in the array as word (4 byte) aligned quantities. This means that some member functions do not work when RArray is instantiated for classes of less than 4 bytes in size, or when the class's alignment requirement is not 4. Be aware that it is possible to get an unhandled exception on hardware that enforces strict alignment. This will affect methods like RArray constructor, Append(..), Insert(..) and [] operator. Try to avoid RArray if you want to store "C" classes. You should
use RPointerArray. Based on runtime extension requirements we can go for Segmented
or Flat type. Issue 13: Presence of Dead-code :
Source: http://www.newlc.com/performance-tuning-code
Set as favorite
Bookmark
Email This
Hits: 631 Comments (9)
![]() shi
written by fiwedding , June 30, 2010 Normally applications have many releases and newer release can have lines of code (methods/data memebers) which was part of old releases and not required any more in your latest release(s), normally we call it as dead-code.Always remove unwanted dead code beacuse it can increase our ROM usage
report abuse
vote down
vote up
Votes: +0
abercrombie london
written by abercrombie london , July 31, 2010 Thanks a lot for sharing. You have done a brilliant job. Your article is truly relevant to my study at this moment, and I am really happy I discovered your website. However, I would like to see more details about this topic. I'm going to keep coming back here.
report abuse
vote down
vote up
Votes: +0
wty
written by cosplay , August 03, 2010 Beautiful little cafe right slap-bang in the middle of the North Laine.
report abuse
vote down
vote up
Votes: +0
...
written by replica handbags , August 03, 2010 if you like replica handbgs, i think you will be instread in
report abuse
vote down
vote up
Votes: +0
abercrombie
written by abercrombie , August 04, 2010 Thank you for taking the time to publish this information very useful!
I’m still waiting for some interesting thoughts from your side in your next post thanks report abuse
vote down
vote up
Votes: +0
nike max 2009 on sale
written by nike max 2009 on sale , August 06, 2010 However mean your nike air max 2010 mens life is meet it and live it; Do not shun it and call it hard names. It is not so bad nike air max 2010 as you are. It looks poorest when you are richest. The nike max 2009 on sale faultfinder will find faults in paradise. Love your new nike air max 2009 life poor as it is. You may perhaps have some pleasant thrilling glorious air max 95 black hours even in a poorhouse. The setting sun is reflected from the blue airmax 95 windows of the alms-house as brightly as from the rich man's blue air max 90 for women abode; the snow melts before its door as early in the spring. I do not see but a quiet mind may nike air max 90 live as contentedly there and have as cheering cheap air max 180 thoughts as in a palace. The town's poor seem to me often to live the most independent air max classic womens shoes lives of any. May be they are simply great nike air max enough to receive without misgiving. Most think that they are above being supported by the town; but it often grey nike air max for men happens that they are not above supporting themselves by dishonest means. Which should be more disreputable. Cultivate poverty men air max shoes like a garden herb like sage. Do not trouble yourself much to get new things whether clothes or women air max shoes friends Turn the old return to them. Things do not change; we change. Sell your clothes and keep your thoughts. Today we have higher nike air max white buildings and wider highways but shorter temperaments and narrower points of nike red air max 2009 view. http://www.sellnikeairmax.com/ CC
report abuse
vote down
vote up
Votes: +0
...
written by pandora bracelets , August 10, 2010 Costing a adolescent, you must prefer to look brilliant, pandora especially pandora bracelet blog in front of your boyfriends. In addition to, you must pandora blog bear attempted gross
report abuse
vote down
vote up
Votes: +0
Cheap Coach Bags
written by Coach Outlet , August 10, 2010 Are you interested in business a Coach handbag made by Coach Outlet Stores? Have you ever visited Coach Factory Outlet food and looked at the category of different coach bags, which is untaken in these outlets?
report abuse
vote down
vote up
Votes: +0
Agreement written by Makena , August 28, 2010 I just wanted to thank you for the article. Before writing something new to my blog, I look through many articles found by means of a special periodical search engine. I'd like to know how you get ready for writing new material.
report abuse
vote down
vote up
Votes: +0
Write comment
|