Re: RES: [Dev-C++] Optimizing C code, what is best??
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Graeme F. <gr...@dr...> - 2003-05-31 08:21:59
|
Greetings, I ran the code you posted and my results were certainly not as impressive as yours. start (C++) 1 (37) 186 2 (35) 186 3 (32) 186 4 (33) 186 start (C++ reverse order) 4 (33) 186 3 (32) 186 2 (35) 186 1 (36) 186 start (C reverse order) 4 (33) 186 3 (32) 186 2 (35) 186 1 (36) 186 I made a few changes - not to the methods but to main where I added a system pause and declared a loop counter so I could change the value. I ran with the following: DWORD64 loop = 100000000; Yes their is a difference but marginal. That difference is important if the code is time critical otherwise it probably doesn't really matter. More importantly is the algorithm, I could rewrite the code to be horrible inefficient (nest a for loop and then replacing the iA*iA with iA+iA). Graeme. |