home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / pascal / 8020 < prev    next >
Encoding:
Internet Message Format  |  1993-01-10  |  2.0 KB

  1. Path: sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!muzzle
  2. From: muzzle@cs.uq.oz.au (Murray Chapman)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: Faster Pascal
  5. Message-ID: <11625@uqcspe.cs.uq.oz.au>
  6. Date: 11 Jan 93 00:42:42 GMT
  7. References: <mitchell.11@odie.ee.wits.ac.za> <1993Jan9.140610.28269@lugb.latrobe.edu.au>
  8. Sender: news@cs.uq.oz.au
  9. Reply-To: muzzle@cs.uq.oz.au
  10. Lines: 47
  11.  
  12. In <1993Jan9.140610.28269@lugb.latrobe.edu.au> cscmd@lux.latrobe.edu.au (Mitch Davis) writes:
  13.  
  14. >In article <mitchell.11@odie.ee.wits.ac.za> mitchell@odie.ee.wits.ac.za (MITCHELL JAMES) writes:
  15. >>G'day all!
  16. >>
  17. >>Bascially, I'm trying to find a way to run Pascal code faster. I have access 
  18. >>to a 486 but this is woefully inadequate (for my needs at least).
  19.  
  20. >Hi there James!
  21.  
  22. >>If anyone has experienced/solved the speed problem, I would greatly 
  23. >>appreciate their advice.
  24.  
  25. >I've had that problem, and I've solved it.  90% of the time, you can
  26. >triple the speed of your program by re-writing it so it is smarter.
  27.  
  28. This is true.
  29.  
  30. Also, it's pretty well-known that on average, your computer spends 90% of
  31. its time in 10% of the program.  In other words, there is no point in
  32. trying to optimize statements that aren't executed multiple times.
  33.  
  34. For example:
  35.  
  36. 1:    R := R * 4;
  37. 2:    for x := 1 to 100 do
  38. 3:      for y := 1 to 100 do
  39. 4:          line(0, 0, Sin(X) * R, Sin(Y) * R);
  40.  
  41. There would not be much point in changing line 1 to assembler code to do two
  42. ASL's, as the speedup would be linear, and not all that much.
  43.  
  44. On the other hand, line 4 is executed 10000 times, and calls 20000 expensive
  45. functions.  Make a lookup table for sin/cos, and you will save yourself 20000
  46. function calls.
  47.  
  48. >>James Mitchell
  49.  
  50. >Mitchell James Davis.
  51.  
  52. Cheers,
  53. Murray
  54. --
  55. ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
  56.   Murray Chapman                           muzzle@cs.uq.oz.au
  57.   University of Queensland                 How many lightbulb jokes does it
  58.   Brisbane, Australia                      take to change the subject?
  59.