Click here to Skip to main content
15,906,574 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: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Mark_Wallace5-May-16 6:47
Mark_Wallace5-May-16 6:47 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Nish Nishant5-May-16 6:48
sitebuilderNish Nishant5-May-16 6:48 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Mark_Wallace5-May-16 7:50
Mark_Wallace5-May-16 7:50 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Nish Nishant5-May-16 7:56
sitebuilderNish Nishant5-May-16 7:56 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
charlieg5-May-16 5:01
charlieg5-May-16 5:01 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Member 47240845-May-16 22:34
Member 47240845-May-16 22:34 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Nish Nishant6-May-16 1:32
sitebuilderNish Nishant6-May-16 1:32 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Member 107319446-May-16 9:26
Member 107319446-May-16 9:26 
Yeah - but as he noted, unroll the loop after your profiler has said "hey - this is a slow part" - not before.

In other words, don't second-guess the compiler - don't "pre-optimize" code that doesn't need it.

Get the steak on the grill, the sizzle will come later.

This is, in fact, one of the early-days lessons from game development and demo-coding. Back then, compilers weren't as intelligent, and sometimes you needed to "help the compiler along" by unrolling loops, or adding a bit of hand-crafted inline-assembler to make things a tad faster.

But you never did this on the first iteration of the code (or at least, you shouldn't have - I am sure many coders did, just like they do today). Instead, you would compile and run the code, and profile/log the speed of various sections, and anywhere it seemed like things were taking longer that they should have, you'd drill down and find the likely culprit, then try to optimize that section (loop-unroll, etc).

Otherwise - without the profiling - you might optimize something that didn't need it, or worse (and this could happen, especially back then), your optimization might actually make things slower (perhaps because your "optimized code" is re-interpreted into something much worse object-code-wise than had you let the compiler do it job normally).

So he isn't saying here not to unroll loops, but rather saying "unroll a loop after you have profiled the code - then profile the code with your unrolled loop, and compare the speed difference to make sure you haven't made things worse".
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Member 47240846-May-16 14:08
Member 47240846-May-16 14:08 
GeneralRe: The Ultimate Question of Programming, Refactoring, and Everything - by Andrey Karpov Pin
Herbie Mountjoy6-May-16 2:34
professionalHerbie Mountjoy6-May-16 2:34 
News[News] Microsoft's hover gestures for Windows phones are magnificent Pin
Nish Nishant5-May-16 3:33
sitebuilderNish Nishant5-May-16 3:33 
GeneralRe: [News] Microsoft's hover gestures for Windows phones are magnificent Pin
Marc Clifton5-May-16 3:57
mvaMarc Clifton5-May-16 3:57 
GeneralRe: [News] Microsoft's hover gestures for Windows phones are magnificent Pin
Nish Nishant5-May-16 4:29
sitebuilderNish Nishant5-May-16 4:29 
GeneralRe: [News] Microsoft's hover gestures for Windows phones are magnificent Pin
Mark_Wallace5-May-16 6:52
Mark_Wallace5-May-16 6:52 
GeneralFor those who like cats (redux). Pin
Maximilien5-May-16 3:28
Maximilien5-May-16 3:28 
GeneralRe: For those who like cats (redux). Pin
Mark_Wallace5-May-16 6:02
Mark_Wallace5-May-16 6:02 
GeneralRe: For those who like cats (redux). Pin
Basildane5-May-16 7:07
Basildane5-May-16 7:07 
GeneralRe: For those who like cats (redux). Pin
90823655-May-16 9:56
90823655-May-16 9:56 
GeneralRe: For those who like cats (redux). Pin
Basildane5-May-16 10:47
Basildane5-May-16 10:47 
GeneralFor all those who like cats... Pin
CDP18025-May-16 2:08
CDP18025-May-16 2:08 
GeneralRe: For all those who like cats... Pin
Member 124968875-May-16 2:59
Member 124968875-May-16 2:59 
GeneralRe: For all those who like cats... Pin
James McCullough5-May-16 3:05
professionalJames McCullough5-May-16 3:05 
GeneralRe: For all those who like cats... Pin
CDP18025-May-16 3:15
CDP18025-May-16 3:15 
GeneralBJOTD Pin
Bassam Abdul-Baki5-May-16 1:32
professionalBassam Abdul-Baki5-May-16 1:32 
GeneralRe: BJOTD Pin
den2k885-May-16 2:02
professionalden2k885-May-16 2:02 

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.