unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Florian Beck <abstraktion@t-online.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Problem with position and find (cl)
Date: Sat, 21 Jun 2008 00:31:14 -0400	[thread overview]
Message-ID: <87ve039zot.fsf@sophokles.streitblatt.de> (raw)
In-Reply-To: barmar-E28F5A.22043120062008@newsgroups.comcast.net

Barry Margolin <barmar@alum.mit.edu> writes:

> In article <87abhfg0mn.fsf@sophokles.streitblatt.de>,
>  Florian Beck <abstraktion@t-online.de> wrote:
>
>> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>> 
>> 
>> > position default test is 'eq, try 'equal
>> 
>> Indeed, many cl-tests default to 'eq.
>> 
>> BTW, what is the reason for this (apart from being a language convention)?
>
> Just because things look similar doesn't mean they're the same.  Imagine 
> if you use a list like (firstname lastname) to represent people, and you 
> have two John Smiths in the group.

Yes, that was what I was trying to explain.

>> 
>> When I try
>> 
>> (let ((start-time (current-time)))
>>   (dotimes (i 1000000)
>>     (position '(1) '((2) (5) (2) 2 x  4 fer fer f r e wqf (1) fr r) :test 
>>     'eq))
>>   (format-time-string "%S" (time-since start-time)))
>> 
>> with 'eq and 'equal I get the same result. So 'eq is not more efficent,
>> is it?
>
> For a single-element list the difference is almost negligible.  Try 
> again with long lists, like 50 or 100 elements long.

I doesn't scale, but not that quickly:

(let ((start-time (current-time))
      (test-list (append (make-list 10000 'x) '((1)))))
  (dotimes (i 1000)
    (position '(1) test-list :test  'equal))
  (format"%.3f" (- (time-to-seconds  (current-time)) (time-to-seconds start-time) )))
      

(let ((start-time (current-time))
      (test-list (append (make-list 10000 'x) '((1)))))
  (dotimes (i 1000)
    (position '(1) test-list :test  'eq))
  (format "%.3f" (- (time-to-seconds  (current-time)) (time-to-seconds start-time) )))

This still takes more or less the same amount of time. (In my case 7.782s
and 7.689s.)

-- 
Florian Beck


  reply	other threads:[~2008-06-21  4:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20 18:30 Problem with position and find (cl) Marc Tfardy
2008-06-20 19:58 ` Marc Tfardy
2008-06-20 20:14   ` Florian Beck
2008-06-20 21:24     ` Thierry Volpiatto
     [not found]     ` <mailman.13619.1213996704.18990.help-gnu-emacs@gnu.org>
2008-06-20 23:14       ` Florian Beck
2008-06-21  2:04         ` Barry Margolin
2008-06-21  4:31           ` Florian Beck [this message]
2008-06-21  4:57         ` Thierry Volpiatto
2008-06-21 10:07       ` Marc Tfardy
2008-06-21 10:38         ` Marc Tfardy
2008-06-21 12:38           ` Thierry Volpiatto
2008-06-20 21:16 ` Thien-Thi Nguyen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87ve039zot.fsf@sophokles.streitblatt.de \
    --to=abstraktion@t-online.de \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).