Click here to Skip to main content
15,900,325 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: goto statement Pin
vl212-Nov-13 1:30
vl212-Nov-13 1:30 
GeneralRe: goto statement Pin
werinus12-Nov-13 1:34
werinus12-Nov-13 1:34 
GeneralRe: goto statement Pin
vl212-Nov-13 1:45
vl212-Nov-13 1:45 
GeneralRe: goto statement Pin
werinus12-Nov-13 2:36
werinus12-Nov-13 2:36 
GeneralRe: goto statement Pin
jschell12-Nov-13 9:44
jschell12-Nov-13 9:44 
GeneralRe: goto statement Pin
Bill_Hallahan12-Nov-13 13:04
Bill_Hallahan12-Nov-13 13:04 
GeneralRe: goto statement Pin
jschell13-Nov-13 9:30
jschell13-Nov-13 9:30 
GeneralRe: goto statement Pin
Bill_Hallahan13-Nov-13 17:23
Bill_Hallahan13-Nov-13 17:23 
jschell:
"Not to mention of course that profiling systems is unlikely to substantially increase the speed of the application. The only time it does lead to substantial increases is when it identifies points which were poorly designed or architected in the first place."

I have found that profiling the code and subsequently optimizing the code can, in some cases, cause significant speedups even in a well-designed and well-implemented system.

However, I don't doubt that it's not desirable to optimize the code in whatever problem domain you worked in. Some things can't be made significantly faster. And, even when code can be sped up a lot, it's not always necessary.

Digital filters, which are used in audio codecs, video codecs, imaging, and sometimes graphics, can be sped up dramatically, such as running from 1.5 to 3 times faster, or rarely even faster, by writing specialized assembly routines that use parallel (SIMD) instructions. Modern Intel and AMD processor have wide registers that allow simultaneous multiples and adds of multiple numbers at the same time. These are Single Instruction Multiple Data (SIMD) instructions. Even Intel's parallel compiler cannot handle the special parallel instructions in an optimal fashion in all cases. There's still a need for hand-written assembly code in some cases.

The C or C++ code to implement the algorithms is not badly designed. The compiler often can't generate the best code using these SIMD instructions today. Compilers can handle much more than in the past, but they still aren't as good as a person yet for some things.

Intel now sells various routines that do mathematical operations, such as a dot-product, and even a modern video codec, and these routines use the SIMD instructions internally, so less SIMD code has to be written today. The routines don't cover all cases though.

In a previous job, I wrote code to rotate an color image using bicubic filtering. I then sped up rotating the image on a page by a factor of 1.7 by writing writing specialized assembly code using SSE1 instructions to do part of the calculations. This was only part of the calculations, but that speedup was very significant and resulted in a competitive product.

Not all the optimizations that I have done involved writing assembly language. For one audio application, I unrolled a loop and that caused a significant speedup. That does make the code harder to read, but I added comments. In this case, the speedup was critical to the application.

For another hypothetical example that is similar to something I did, imagine the profiler shows most of the time is spent sorting the data and the code is using a radix sort algorithm. Quicksort is generally better than radix sort, but if sorting 7 or fewer items, quicksort, heapsort, a radix sort, and other advanced sort algorithms are actually slower than a very simple sort routine. A specialized sort routine written for just 7 items will be very, very, fast.

If the problem domain usually had fewer than 8 items to sort, then a good optimization might be to choose the appropriate sort routine based on the number of items to be sorted. I have also seen significant improvements with that type of optimization, although this specific case is hypothetical. The actual case where I did something similar to this is difficult to explain.

My point is, while most of the time the code I worked on didn't need to be optimized, occasionally I've seen optimization result in significant improvements in performance.

To quote Knuth again, ""We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil""

Of course, Knuth was guessing those numbers. 86.3% of statistics are made up on the spot. Wink | ;)

modified 14-Nov-13 0:25am.

GeneralRe: goto statement Pin
jschell14-Nov-13 7:50
jschell14-Nov-13 7:50 
GeneralRe: goto statement Pin
Bill_Hallahan14-Nov-13 14:02
Bill_Hallahan14-Nov-13 14:02 
GeneralRe: goto statement Pin
jschell12-Nov-13 9:46
jschell12-Nov-13 9:46 
GeneralRe: goto statement Pin
Bill_Hallahan12-Nov-13 13:25
Bill_Hallahan12-Nov-13 13:25 
GeneralRe: goto statement Pin
jschell13-Nov-13 9:49
jschell13-Nov-13 9:49 
GeneralRe: goto statement Pin
Stefan_Lang12-Nov-13 20:50
Stefan_Lang12-Nov-13 20:50 
GeneralRe: goto statement Pin
Bill_Hallahan12-Nov-13 12:32
Bill_Hallahan12-Nov-13 12:32 
GeneralRe: goto statement Pin
Stefan_Lang12-Nov-13 21:34
Stefan_Lang12-Nov-13 21:34 
GeneralRe: goto statement Pin
Bill_Hallahan13-Nov-13 7:16
Bill_Hallahan13-Nov-13 7:16 
GeneralRe: goto statement Pin
_Maxxx_10-Nov-13 14:35
professional_Maxxx_10-Nov-13 14:35 
GeneralRe: goto statement Pin
Tarek Elqusi10-Nov-13 18:46
professionalTarek Elqusi10-Nov-13 18:46 
GeneralRe: goto statement Pin
Mark_Wallace10-Nov-13 20:47
Mark_Wallace10-Nov-13 20:47 
GeneralRe: goto statement Pin
Mark H210-Nov-13 21:56
Mark H210-Nov-13 21:56 
GeneralRe: goto statement Pin
Stefan_Lang10-Nov-13 23:24
Stefan_Lang10-Nov-13 23:24 
GeneralRe: goto statement Pin
vl211-Nov-13 7:49
vl211-Nov-13 7:49 
GeneralRe: goto statement Pin
jaybus5610-Nov-13 22:11
jaybus5610-Nov-13 22:11 
GeneralRe: goto statement Pin
Stefan_Lang10-Nov-13 23:13
Stefan_Lang10-Nov-13 23:13 

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.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   483 votes