emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] use tail pointer for LOOP


From: tomas
Subject: Re: [PATCH] use tail pointer for LOOP
Date: Thu, 17 Jun 2010 16:05:01 +0200
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jun 17, 2010 at 12:03:16PM +0200, Thien-Thi Nguyen wrote:
> () address@hidden
> () Thu, 17 Jun 2010 11:22:32 +0200
> 
>    Cute. You all are successfully keeping me from work. Enjoing it ;-)
> 
>    Here are the results. Attached the modified source.
> 
>      copy1: (1.058881 5 0.7366780000000048)
>      copy2: (1.27958 6 0.8913360000000026)
>      copy3: (1.337353 6 0.9249420000000015)
> 
>    Still the reverse version is the winner. Yours seems to be a tad slower
>    (although I wouldn't know whether it's in the noise).
> 
>    But  it looks so sharp ;-)
> 
> How about this one?
> 
> (defun copy4 (lst)
>   "Return a copy of LST."
>   (let* ((box (list nil))
>          (tp box))
>     (while lst
>       (setq tp (setcdr tp (list (pop lst)))))
>     (cdr box)))

Here you go:

  copy1: (1.115929 5 0.7795429999999997)
  copy2: (1.210733 5 0.8172469999999996)
  copy3: (1.2816079999999999 5 0.8502519999999998)
  copy4: (1.295846 5 0.9325959999999993)

(I did implement the garbage-collect-before-each-run as you suggested in
your other mail: this can be nicely seen in the constant number "5"
above).

I won't spam this list with the modified source (unless someone clamours
for it, that is).

So without the GC the gap narrows significantly. But still: reverse's
the king of the hill.

OTOH, the differences in GC times start to be a considerable fraction of
the whole difference, so I might be measuring noise anyway.

Seems we can't beat an old Lisp idiom (my guess is that Lisp is alien
technology, but hey).

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFMGiuNBcgs9XrR2kYRApnTAJ9Lo7J8EHjOr8JMthPQa/E9zwrEIQCePKI4
b7laoSJWtxDrlrzPeDNkhzE=
=S9WC
-----END PGP SIGNATURE-----



reply via email to

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