all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Vector and List Performance
Date: Wed, 10 Jun 2009 10:24:38 +0200	[thread overview]
Message-ID: <7c63f45we1.fsf@pbourguignon.anevia.com> (raw)
In-Reply-To: 629c22c4-bad6-43cd-9386-ca21713b088b@s16g2000vbp.googlegroups.com

Nordlöw <per.nordlow@gmail.com> writes:

> On Jun 9, 2:51 pm, p...@informatimago.com (Pascal J. Bourguignon)
> wrote:
>> Nordlöw <per.nord...@gmail.com> writes:
>> > Aahh, we needed a macro instead:
>>
>> > (defmacro bench (&rest forms)
>> >     "Convenience wrapper for benchmark-run-compiled."
>> >     `(let ((n 10))
>> >        (/ (nth 0 (benchmark-run n ,@forms)) n)))
>>
>> > This gives a reasonable difference in performance.
>>
>> > By the way, does elisp lists have extra pointers to the middle of the
>> > list (a skip-list)?
>>
>> No, because it wouldn't be efficient to have to maintain them.
>>
>> (let* ((c (list 7 8 9))
>>        (b (list* 4 5 6 c))
>>        (a (list* 1 2 3 b)))
>>     (push -1 (cddr c))  (push -2 (cddr c))  ; you may have to update a big number of skip-lists!
>>     (list a b c))
>> -->
>> ((1 2 3 . #1=(4 5 6 . #2=(7 8 -2 -1 9))) #1# #2#)
>>
>> (deftype list () '(or null (cons t list))) ; nothing more.
>>
>> --
>> __Pascal Bourguignon__
>
> I tested the performance difference and strangely the vector version
> of my benchmarking is only faster when the number of elements exceeds
> roughy 1000. Why is this? Shouldn' aref() always be faster than nth
> regardless of the size of the sequence?

How could we say?  You don't provide the full source of what you tested.

Check my other post in this thread, and see how faster the vector
accesses are.  Try the same form in your CL implementation, and report
the results here.

-- 
__Pascal Bourguignon__


  reply	other threads:[~2009-06-10  8:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 17:27 Vector and List Performance Nordlöw
2009-06-08 19:57 ` Tassilo Horn
2009-06-09  9:30 ` Pascal J. Bourguignon
2009-06-09 11:30   ` Nordlöw
2009-06-09 12:51     ` Pascal J. Bourguignon
2009-06-09 18:13       ` Nordlöw
2009-06-10  8:24         ` Pascal J. Bourguignon [this message]
     [not found]         ` <7c63f45we1.fsf@pbourguignon.informatimago.com>
2009-06-10  8:36           ` Pascal J. Bourguignon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7c63f45we1.fsf@pbourguignon.anevia.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.