[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Vector and List Performance
From: |
Nordlöw |
Subject: |
Re: Vector and List Performance |
Date: |
Tue, 9 Jun 2009 11:13:45 -0700 (PDT) |
User-agent: |
G2/1.0 |
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?
/Per Nordlöw