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

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

Re: Vector and List Performance


From: Pascal J. Bourguignon
Subject: Re: Vector and List Performance
Date: Wed, 10 Jun 2009 10:24:38 +0200
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (gnu/linux)

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 via email to

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