help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make-hash-table :size


From: Oliver Scholz
Subject: Re: make-hash-table :size
Date: Sun, 29 Aug 2004 23:44:06 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (windows-nt)

Oliver Scholz <alkibiades@gmx.de> writes:
[...]
> I assume that you use some extended CL compatibility package other
> than the one that comes with stock Emacs?  If that one overwrites
> Emacs' `assoc' (which is implemented in C) with a function implemented
> in Lisp, that could explain the profiling differences.
[...]

Indeed:  Using actual calls to cl.el's `assoc*' for comparision:

Function Name      Call Count  Elapsed Time  Average Time
=================  ==========  ============  ============
test-cl-assoc      10000       0.3100000000  3.10...e-005
test-alist-access  10000       0.09          9e-006
test-hash-access   10000       0.05          5e-006




(defconst test-alist
  (let ((lst (make-list 14 '(lirum . larum))))
    (append lst '((alpha . beta)))))

(defconst test-hash
  (let ((hash (make-hash-table :size 15 :test 'eq)))
    (puthash 'alpha 'beta hash)
    hash))

(defun test-hash-access (table test key)
  (gethash key table))

(defun test-alist-access (table test key)
  (cdr (assq key table)))

(defun test-cl-assoc (table test key)
  ;; Passing the test here as an argument is necessary in order to
  ;; prevent `assoc*' being replaced via a compiler macro.
  (cdr (assoc* key table :test test)))

(dolist (f '(test-hash-access
             test-alist-access
             test-cl-assoc))
  (byte-compile f))

(elp-instrument-list  '(test-hash-access
                        test-alist-access
                        test-cl-assoc))

(defun test-run ()
  (interactive)
  (dotimes (ignore-me 10000)
    (test-hash-access test-hash 'eq 'alpha)
    (test-alist-access test-alist 'eq 'alpha)
    (test-cl-assoc test-alist 'eq 'alpha))
  (elp-results))



    Oliver
-- 
13 Fructidor an 212 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]