From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: About performance, hash-tables and garbage collection Date: Fri, 20 Sep 2002 19:06:38 +0200 Organization: Olymp Sender: help-gnu-emacs-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1032555195 9496 127.0.0.1 (20 Sep 2002 20:53:15 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 20 Sep 2002 20:53:15 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17sUm2-0002T2-00 for ; Fri, 20 Sep 2002 22:53:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17sUmS-0008By-00; Fri, 20 Sep 2002 16:53:40 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!dialin-145-254-197-107.arcor-ip.NET!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 26 Original-NNTP-Posting-Host: dialin-145-254-197-107.arcor-ip.net (145.254.197.107) Original-X-Trace: fu-berlin.de 1032535623 5837908 145.254.197.107 (16 [87814]) X-Orig-Path: hermes!nobody X-Operating-System: Linux from Scratch X-Attribution: os X-Face: "HgH2sgK|bfH$;PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6;Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu) Cancel-Lock: sha1:HIxY1CUEfJqrR0SOcM5COtieb/w= Original-Xref: nntp.stanford.edu gnu.emacs.help:105117 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:1673 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1673 I am currently writing a library in which the main function has an inner loop that may run several thousand times. So I care a bit about the performance of this inner loop. 1. I have read that hash-tables have a little overhead and that association lists are a little bit faster, when they contain not more than about a dozen of key-value pairs. It is _possible_ that I have to maintain several hundreds or thousand of key/value pairs, but in most cases it will be only a dozen or so. So my question is: how much overhead has a hashtable? Makes it sense to add a condition, like this: (if (> ncolours 15) (gethash colour colour-map) (cdr (assoc (colour colour-map)))) 2. I noticed that the garbage collector hits in a little bit too often, though I do not know why. I have a lot of `setq'-statements like `(setq pointer (1+ pointer))'. Is it possible that they are the cause? If so, what could I do? -- Oliver -- Jour de la Raison de l'Année 210 de la Révolution Liberté, Egalité, Fraternité!