MarsJupiter - Family shareware  
 
 Wednesday, 08 October 2008
C & C++ Code Optimisation
taking_notes.jpg

The area of code optimisation has long interested me.

I started off my programming career in assembly language on the venerable BBC Microcomputer, one of my first exercises was to convert an efficient implementation of Conways game of Life, the cellular automation game that had been written in BASIC to 6502 assembly language.

My initial implementaion had a bug! a test that whether a cell was worth calculating caused the machine code to always calculate every cell. The net result was a program that worked, a program that was inherently  perhaps a 100 times faster than the BASIC version did in fact operate marginally slower.

This bought home to me the importance of using the correct algorithms and efficient programming.

Later in my career I worked using Alex an interpreted language, but one that does have a callable API allowing you to avoid the slowness of any interpreter. In this particular project, the language. Alex used almost all the right algorithms and extensive profiling revealed very few black spots. Despite this it did run at too slow a speed for the project in question. extensive work on just about all section of the code did bring about a near doubling of the speed.

This made me question the old adage of optimisation, which is essentially don't waste time on it, but at the end of a project profile and deal with the problem areas. I think that with big projects you should always be keeping at least a weather eye on optimistion, as sometimes the small issues mount up, and to have the intelligence to see the obviously key areas of a project in advance and not to be left trying to "hack" in optimsations at the last.

Using C++ in particular raises a number of interesting aspects to opimisation.  In C++ you tend to operate at a much higher level than in C. When you use a null terminated string in C there is no question in your mind as to what you are getting for your money. You know for example that if you write:

for (i = 0; i < strlen(strText);i++){

}

then it is going to be very inefficient.  But when you are in C++, just how bad is:

for (i = 0; i < strText.length();i++){

}

It is these questions and others that I intend to try and address here.

 

Filter     Order     Display # 
Item Title
Compressed bitset class
replacement bitset C++ class - development log
A simple non standard allocator for C++ classes
Memory allocation in C/C++
The curse of the virtual destructor
Is optimisation still an issue
Benchmarking the standard template library STL
 
<< Start < Prev 1 Next > End >>
Results 1 - 7 of 7
Products

Callisto - Newsreader/Bulletin Board Browser. The best way to
browse usenet and bulletin boards.
Newsreader/BBS Browser


Foboz - Meta Search Engine, The best Meta Search Engine, searching
hundreds of search engines from the best sites across the web.
Meta Search Engine


 

ThereIWas - Intelligent Favorites/History Toolbar for internet
Explorer
Favorites/History Toolbar


 

WhereWasi? - History Word Search Toolbar for Internet Explorer
History Word Search Toolbar

Main Menu
Home
MarsJupiter Products
Callisto Newsreader - News Reader/Forum Browser
Foboz Meta Search Engine - Unbeatable Results
Where Was I?
ThereIWas - intelligent history/favorites
UpFront - Ingres FRS GUI
Company News
Contact Us
FAQ
MarsJupiter Forums
Affiliate Programme
Alex Programming
Resources
The Web Links
The Daily Blat
Newsflash
Current Releases
Callisto News Reader/Bulletin Board Browser 3.14 has now been released:
Download Callisto here
Tucows rating:
Foboz Meta Search Engine 1.52 has been released:
Download Foboz here
Tucows rating:
WhereWAsI? - Internet Explorer history search toolbar 1.50 has been released:
Download WhereWasI? here
AuntyJean - Internet Explorer family friendly Filter toolbar 1.00 has been released:
Download AuntyJean here
ThereIWas- Intelligent Favorites/history Internet Explorer toolbar 1.02 has been released:
Download ThereIWas here
Coop Ad Link Module
Debt|Mortgages|Credit Cards UK|Mortgages|Cheap Loan
 
Go to top of page  Home | MarsJupiter Products | Callisto Newsreader - News Reader/Forum Browser | Foboz Meta Search Engine - Unbeatable Results | Where Was I? | ThereIWas - intelligent history/favorites | UpFront - Ingres FRS GUI | Company News | Contact Us | FAQ | MarsJupiter Forums | Affiliate Programme | Alex Programming | Resources | The Web Links | The Daily Blat |