Click here to Skip to main content
15,886,617 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to give a static link by using static text control in VC++ 6.0 or MFC ? Pin
anuragguptartm3-Mar-08 21:06
anuragguptartm3-Mar-08 21:06 
AnswerRe: How to give a static link by using static text control in VC++ 6.0 or MFC ? Pin
Hamid_RT3-Mar-08 21:11
Hamid_RT3-Mar-08 21:11 
AnswerRe: How to give a static link by using static text control in VC++ 6.0 or MFC ? Pin
David Crow4-Mar-08 2:56
David Crow4-Mar-08 2:56 
QuestionHow to handle notify message in both reflect way and normal way? Pin
followait3-Mar-08 20:54
followait3-Mar-08 20:54 
AnswerRe: How to handle notify message in both reflect way and normal way? Pin
Alexander M.,3-Mar-08 21:15
Alexander M.,3-Mar-08 21:15 
GeneralRe: How to handle notify message in both reflect way and normal way? Pin
followait3-Mar-08 21:26
followait3-Mar-08 21:26 
General[solved] Pin
followait3-Mar-08 22:16
followait3-Mar-08 22:16 
GeneralSpeeding up a loop [modified] Pin
73Zeppelin3-Mar-08 20:51
73Zeppelin3-Mar-08 20:51 
I've been doing some profiling and have come across a portion of my code that I suspect can be sped up (although it is already quite simple). I have a loop where I do a calculation. In this form:

for (int i = max; i >= 0; i--)
    for (int j = 0; j <= limit; j++)
        value = calculation(i,j);


The loop is blazingly fast. I can do about 20,000 iterations in a fraction of a second. Then I added an if-elseblock:

for (int i = max; i >= 0; i--) {
    for (int j = 0; j <= limit; j++) {
        if (quantity > 0)
            value = calculation(i,j);      // calculation dependent on i and j
        else
            value = 0.0;
    }
}


In the above form, the 20,000 iterations can take about a minute. Speed is very important and the simple addition of the if-else brings a huge performance hit - I suspect because the compiler can't optimize the loop. Does anyone see a creative way to remove this if-else block and replace it with something the compiler can optimize? It seems it should be simple, but I can't really think of anything off-hand.










modified on Tuesday, March 4, 2008 3:29 AM

GeneralRe: Speeding up a loop Pin
Maxwell Chen3-Mar-08 20:58
Maxwell Chen3-Mar-08 20:58 
GeneralRe: Speeding up a loop Pin
73Zeppelin3-Mar-08 21:28
73Zeppelin3-Mar-08 21:28 
GeneralRe: Speeding up a loop Pin
CPallini3-Mar-08 22:00
mveCPallini3-Mar-08 22:00 
GeneralRe: Speeding up a loop Pin
73Zeppelin3-Mar-08 22:16
73Zeppelin3-Mar-08 22:16 
GeneralRe: Speeding up a loop Pin
El Corazon4-Mar-08 8:37
El Corazon4-Mar-08 8:37 
GeneralActivex + Network Credentials Pin
Aamol M3-Mar-08 20:43
Aamol M3-Mar-08 20:43 
GeneralReading from file and displaying in screen Pin
Chandrasekharan P3-Mar-08 18:51
Chandrasekharan P3-Mar-08 18:51 
QuestionRe: Reading from file and displaying in screen Pin
Rajesh R Subramanian3-Mar-08 19:08
professionalRajesh R Subramanian3-Mar-08 19:08 
GeneralRe: Reading from file and displaying in screen Pin
Chandrasekharan P4-Mar-08 17:25
Chandrasekharan P4-Mar-08 17:25 
GeneralRe: Reading from file and displaying in screen Pin
led mike3-Mar-08 19:10
led mike3-Mar-08 19:10 
GeneralRe: Reading from file and displaying in screen Pin
Mark Salsbery4-Mar-08 5:55
Mark Salsbery4-Mar-08 5:55 
GeneralRe: Reading from file and displaying in screen Pin
led mike4-Mar-08 8:50
led mike4-Mar-08 8:50 
GeneralRe: Reading from file and displaying in screen Pin
Mark Salsbery4-Mar-08 8:57
Mark Salsbery4-Mar-08 8:57 
GeneralRe: Reading from file and displaying in screen Pin
led mike4-Mar-08 9:03
led mike4-Mar-08 9:03 
GeneralRe: Reading from file and displaying in screen Pin
Mark Salsbery4-Mar-08 9:10
Mark Salsbery4-Mar-08 9:10 
GeneralRe: Reading from file and displaying in screen Pin
Mark Salsbery4-Mar-08 9:12
Mark Salsbery4-Mar-08 9:12 
GeneralRe: Reading from file and displaying in screen [modified] Pin
led mike4-Mar-08 9:15
led mike4-Mar-08 9:15 

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.