Click here to Skip to main content
16,005,467 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Screen Capture and Getting pixels? Pin
dSolariuM16-Apr-06 6:59
dSolariuM16-Apr-06 6:59 
GeneralRe: Screen Capture and Getting pixels? Pin
bob1697216-Apr-06 7:36
bob1697216-Apr-06 7:36 
QuestionOptimizing Pin
hint_5416-Apr-06 4:04
hint_5416-Apr-06 4:04 
AnswerRe: Optimizing Pin
Stephen Hewitt16-Apr-06 4:56
Stephen Hewitt16-Apr-06 4:56 
AnswerRe: Optimizing Pin
bob1697216-Apr-06 6:39
bob1697216-Apr-06 6:39 
GeneralRe: Optimizing Pin
hint_5416-Apr-06 10:20
hint_5416-Apr-06 10:20 
GeneralRe: Optimizing Pin
bob1697217-Apr-06 5:46
bob1697217-Apr-06 5:46 
AnswerRe: Optimizing Pin
El Corazon16-Apr-06 15:30
El Corazon16-Apr-06 15:30 
hint_54 wrote:
I need a few c++ code optimizing tips. Anybody knows where I can find good ones?


As already mentioned, measure first. Always keep in mind the 80/20 rule (depending on who is talking this might even be referred to as a 90/10 rule -- I prefer 80/20 because that usually assumes you have not optimized yet, Wink | ;) ): 80% of the time is spent in 20% of the code, when you have optimized you might actually reach the 90/10.

Optimize the code that is A) called the most often B) more time is spent in the code. These could be two different areas, "A" could be a short module that even saving 2% of the overhead within will make a difference because of how often it is called. "B" could be a long routine that could be redesigned to spend less time within.

Reduce redundancy. If you call cos(angle) 10 times for the same angle, consider making a local variable to hold the result and reuse the result 10 times rather than calculate the cosine of the angle 10 different times for the same angle.

That may sound obvious, but you would be surprised at how many people don't think about it. Also don't replace a single point of reduncany without a check, usually it is still faster to allocate the local variable and store the result, but for some CPU math instructions it is easier to calculate twice than to allocate the memory use it and deallocate at the end.

That is why measuring is extremely important. You will discover faster ways yourself, especially in algorithms, because you will get to know your own code better.

_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
QuestionBitmap pixels Pin
nikhilsai16-Apr-06 3:06
nikhilsai16-Apr-06 3:06 
AnswerRe: Bitmap pixels Pin
eli1502197916-Apr-06 3:24
eli1502197916-Apr-06 3:24 
GeneralRe: Bitmap pixels Pin
bob1697216-Apr-06 15:49
bob1697216-Apr-06 15:49 
AnswerRe: Bitmap pixels Pin
Hamid_RT16-Apr-06 6:33
Hamid_RT16-Apr-06 6:33 
AnswerRe: Bitmap pixels Pin
MANISH RASTOGI16-Apr-06 18:39
MANISH RASTOGI16-Apr-06 18:39 
Questionhow come I can not use the Release( ) methord of CComPtr? Pin
ewighell16-Apr-06 2:41
ewighell16-Apr-06 2:41 
AnswerRe: how come I can not use the Release( ) methord of CComPtr? Pin
RChin16-Apr-06 3:06
RChin16-Apr-06 3:06 
AnswerRe: how come I can not use the Release( ) methord of CComPtr? Pin
Stephen Hewitt16-Apr-06 4:21
Stephen Hewitt16-Apr-06 4:21 
AnswerRe: how come I can not use the Release( ) methord of CComPtr? Pin
ewighell16-Apr-06 15:25
ewighell16-Apr-06 15:25 
QuestionMultiple instances of a DLL Pin
Virtek16-Apr-06 2:38
Virtek16-Apr-06 2:38 
AnswerRe: Multiple instances of a DLL Pin
eli1502197916-Apr-06 3:21
eli1502197916-Apr-06 3:21 
GeneralRe: Multiple instances of a DLL Pin
Virtek16-Apr-06 4:19
Virtek16-Apr-06 4:19 
GeneralRe: Multiple instances of a DLL Pin
Michael Dunn16-Apr-06 6:14
sitebuilderMichael Dunn16-Apr-06 6:14 
Questionfinding files with a certain extension Pin
SWDevil16-Apr-06 2:26
SWDevil16-Apr-06 2:26 
AnswerRe: finding files with a certain extension Pin
shortwave16-Apr-06 2:51
shortwave16-Apr-06 2:51 
GeneralRe: finding files with a certain extension Pin
SWDevil16-Apr-06 2:58
SWDevil16-Apr-06 2:58 
GeneralRe: finding files with a certain extension Pin
shortwave16-Apr-06 3:03
shortwave16-Apr-06 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.