home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20983 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  1.7 KB

  1. Path: sparky!uunet!mcsun!sun4nl!tuegate.tue.nl!svin09!wsinpa04!wstomv
  2. From: wstomv@wsinpa04.win.tue.nl (Tom Verhoeff)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Why is new(p) so slow in THINK Pascal?
  5. Keywords: THINK Pascal, dynamic variables
  6. Message-ID: <4940@svin09.info.win.tue.nl>
  7. Date: 8 Jan 93 11:58:05 GMT
  8. Sender: news@svin09.info.win.tue.nl
  9. Reply-To: wstomv@win.tue.nl
  10. Lines: 25
  11.  
  12. In order to compare some sorting procedures for linked lists (implemented
  13. in THINK Pascal) I applied them to random lists of varying lengths.
  14. It turns out that the procedure new(p), which allocates storage for
  15. a dynamic variable pointed to by p, is extremely slow.  Does anyone
  16. know why?  New-ing a thousand items takes a noticeable time, new-ing
  17. 10,000 items takes minutes (on my lowly SE/30).
  18.  
  19. I did call MaxApplZone at the very beginning of my program.  I also
  20. tried various numbers of calls to MoreMasters, without avail.
  21. I presume that dynamic variables in THINK Pascal are stored in
  22. non-relocatable blocks (where can I find that information; in my 4.0
  23. manuals I couldn't find a clue), and therefore MoreMasters would not
  24. be useful anyway.
  25.  
  26. My practical solution is to create a FreeList of free dynamic variables
  27. and prime it at the beginning with a sufficient number items.
  28. Instead of new and dispose I then use NewElement and DisposeElement
  29. defined in terms of the FreeList.  Now it works like a train, except...
  30. that priming is still incredibly slow (fortunately to be done only once).
  31.  
  32.     Tom
  33. -- 
  34. INTERNET: wstomv@win.tue.nl  /    Eindhoven University of Technology
  35. VOICE: +31 40 47 41 25      /    Dept of Mathematics & Computing Science
  36. FAX: +31 40 43 66 85       /    PO Box 513, NL-5600 MB Eindhoven, Netherlands
  37.