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