Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/07/07 13:16
Read: times


 
#142860 - Balance
Responding to: ???'s previous message
Jan said:
I think it makes sense to build such snippets - this sort of algorithms is used widely, has well defined inputs and outputs, and IMHO it always makes sense to try to do things as good as possible (hello, Russ! :-) )

Hello, Jan. Thanks for inviting me to the party!

Of course I agree that it always makes sense to do the best job possible, and (as you know) I have spent many hours playing around with little snippets like you are talking about, trying to shave off a cycle here or a byte there. That sort of thing can be very educational and a lot of fun.

However, when working on a real project, for a real employer who's paying me real money, I think it's important to recognize that "best" doesn't necessarily mean "smallest" or "fastest". You said it yourself:

The prudent programmer tries to perform a multi-variable optimisation.

It's easy to focus on easily-measured variables like code size and execution speed. However, there are also less tangible things to consider, such as maintainability, portability, reliability, and cost. The first trick is to learn to balance all of the variables. Then when you have that figured out, try to realize that the importance of each one of the variables varies from project to project and situation to situation.

Sometimes it will make sense to make the code fast instead of making it small. Sometimes it won't.

Sometimes it will make sense to use ASM instead of C. Sometimes it won't.

Sometimes it will make sense to add hardware instead of adding complexity to the software. Sometimes it won't.

Sometimes it will make sense to spend an hour making a function two cycles faster instead of going home to play ball with your kid. Sometimes it won't.

-- Russ


List of 32 messages in thread
TopicAuthorDate
CRC16 CCITT - What a challenge!            01/01/70 00:00      
   Have you seen this?            01/01/70 00:00      
      Of course!            01/01/70 00:00      
         Balance            01/01/70 00:00      
            I know, Russ,            01/01/70 00:00      
         Code? What code?            01/01/70 00:00      
            in the code library - look to the left column            01/01/70 00:00      
               Thanks! I missed that note in the first post.            01/01/70 00:00      
   I need a hint            01/01/70 00:00      
      write down the bits            01/01/70 00:00      
         Thanks for the hint            01/01/70 00:00      
            Your observations plus a comparison in C            01/01/70 00:00      
               The rest of the story ...            01/01/70 00:00      
                  Compilers, but Keil C51 8.09 for the stated 28~            01/01/70 00:00      
                  and this processes only a nibble, isn't it...            01/01/70 00:00      
                     No, it process the entire byte.            01/01/70 00:00      
                        now it\'s my pencil time...            01/01/70 00:00      
                           FYFI            01/01/70 00:00      
                              Clarification re: 8-bit optimized term            01/01/70 00:00      
                              on optimisation            01/01/70 00:00      
                                 Jan's optimization            01/01/70 00:00      
                                    Re: on optimization            01/01/70 00:00      
                                       Can you please be more specific?            01/01/70 00:00      
                                          More specifically ...            01/01/70 00:00      
            and what            01/01/70 00:00      
               More on checksums            01/01/70 00:00      
   No reason to hide the excreted code            01/01/70 00:00      
      Excreted code needs context like any other code            01/01/70 00:00      
   One More Comment            01/01/70 00:00      
      ... and a marginal remark ...            01/01/70 00:00      
         Init all ones frequently specified            01/01/70 00:00      
   18 cycles            01/01/70 00:00      

Back to Subject List