home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / arch / 10611 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  2.0 KB

  1. Xref: sparky comp.arch:10611 comp.lang.misc:3588
  2. Newsgroups: comp.arch,comp.lang.misc
  3. Path: sparky!uunet!spool.mu.edu!uwm.edu!daffy!snake38.cs.wisc.edu!lawrence
  4. From: lawrence@snake38.cs.wisc.edu (Thomas Lawrence)
  5. Subject: Re: Hardware Support for Numeric Algorithms
  6. Message-ID: <1992Nov11.145718.24305@daffy.cs.wisc.edu>
  7. Sender: news@daffy.cs.wisc.edu (The News)
  8. Organization: /usr/lib/news/rn/organization
  9. References: <1992Nov5.202412.7266@linus.mitre.org> <1992Nov10.153705.27804@yrloc.ipsa.reuter.COM> <1992Nov11.100555.4706@smds.com>
  10. Date: Wed, 11 Nov 1992 14:57:18 GMT
  11. Lines: 28
  12.  
  13. Well, I can't speak for anyone other than me, but here is a technique I
  14. find useful when I have to develop code that runs screamingly fast yet is
  15. rather complex when "optimized" by hand.
  16.  
  17. First, I develop some working algorithm that's SIMPLE enough to understand
  18. by looking at it.  This means it has absolutely no performance helpers.
  19. (No caches, hash tables, etc.)  I debug that code to make sure it works
  20. properly (basically debugging my algorithm, and not worrying about any
  21. optimizations).  [Note that there may be goto's in the code; I don't
  22. deal with that.  I've gotten into the habit of using them instead of
  23. do-while loops in some cases.]
  24.  
  25. THEN I go and put COMMENTS around the entire code so that the compiler
  26. won't see it.  I use the simple code as guidelines for developing more
  27. efficient code.
  28.  
  29. The end result is a source file containing
  30.   - Some straight-forward but inefficient code which is enclosed in comments
  31.     so that when I come back 3 months from now, I can use it to see what I
  32.     was trying to do.
  33.   - Some twisted, optimized code (with comments indicating what was done
  34.     to it from the original model, so I can fix it 3 months from now).
  35.  
  36. If it happens that I have to scrap the optimized code in a few months because
  37. I forgot what it did, that's ok because I still have the original working
  38. version in the text file which I can modify as necessary.  Or if I want
  39. I can modify the optimized version.  It leaves the options open.
  40.  
  41.