From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman" Newsgroups: gmane.emacs.devel Subject: Re: What is the difference between looking-at and an anchored search? Date: Thu, 17 Jul 2008 16:17:26 +0200 Message-ID: References: <487F2985.9080103@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_32590_6223315.1216304246920" X-Trace: ger.gmane.org 1216304279 31318 80.91.229.12 (17 Jul 2008 14:17:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jul 2008 14:17:59 +0000 (UTC) Cc: Emacs Devel To: "Miles Bader" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 17 16:18:47 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KJUJY-00029G-SE for ged-emacs-devel@m.gmane.org; Thu, 17 Jul 2008 16:18:37 +0200 Original-Received: from localhost ([127.0.0.1]:60974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJUIf-00032H-LW for ged-emacs-devel@m.gmane.org; Thu, 17 Jul 2008 10:17:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJUIW-0002zw-8t for emacs-devel@gnu.org; Thu, 17 Jul 2008 10:17:32 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJUIU-0002zI-VF for emacs-devel@gnu.org; Thu, 17 Jul 2008 10:17:31 -0400 Original-Received: from [199.232.76.173] (port=44042 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJUIU-0002zB-P9 for emacs-devel@gnu.org; Thu, 17 Jul 2008 10:17:30 -0400 Original-Received: from fg-out-1718.google.com ([72.14.220.154]:63456) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KJUIT-00069k-5S for emacs-devel@gnu.org; Thu, 17 Jul 2008 10:17:30 -0400 Original-Received: by fg-out-1718.google.com with SMTP id l26so2808522fgb.30 for ; Thu, 17 Jul 2008 07:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=f4D2yLFVTrS5PerT6NbWCb+MBA4ZNdtJ9zWGl10GySI=; b=tNKZEdGuSivhMaR7Xtc/C2qOc1+gyqUs50f89gJz/iPrVxbmdz5qmUzVkaA7sBjVap eofc6XCDvYa3Rv+SFqxmRWpxegQd3A1p+/MU++A6MOtZw8rDk6a3QNvyah/h9yISoCAQ nLTFrwLXreuOzFSwu8K48Unynf1/rFEMBphuU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=jE8/Z8brYxPl1TG2IuyEgH91JmimZuA4o40t+NR42Oc7O4HCU3npcK0aJ8GIQDdQmr Aun7Re3j9Cs4XxVqvSPnFYXPpw3VeGL0LGJqXzKDIKnyyb3qiY6Yl+p2OncZzaWEkgop aXkRhCSmSW4WqsF2qfnH0QmECcn1LA22iA2os= Original-Received: by 10.86.65.11 with SMTP id n11mr4071301fga.64.1216304246943; Thu, 17 Jul 2008 07:17:26 -0700 (PDT) Original-Received: by 10.86.66.2 with HTTP; Thu, 17 Jul 2008 07:17:26 -0700 (PDT) In-Reply-To: X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100889 Archived-At: ------=_Part_32590_6223315.1216304246920 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/17/08, Miles Bader wrote: > "Lennart Borgman" writes: > > >> > Yes, that is one possibility. But then perhaps I would assume that > >> > re-search-forward better might optimize that search since it can > >> > (in theory) cut off the searching at BOUND. In the case I am > >> > looking at performance is important. > >> > >> Why don't you time it? > > > > Because I thought someone here knew more about the performance > differences > > (if any). I am also a bit surprised that looking-at does not have a BOUND > > parameter and hoped to get some comments on that. > > Offhand it doesn't fit looking-at's interface particulary well -- while > you can come up with semantics for such a parameter, they're not > something obviously useful as is the case for searches. Also, for > typical uses of looking-at, the performance difference isn't a factor. > > Anyway, it seems a lot better to get actual data than > pontificate... premature optimization is the root of all evil, > after all... :-) It looks like the performance is pretty equal. Here is my test code: (benchmark-elapse (goto-char (point-min)) (let ((times 10000)) (while (> times 0) (setq times (1- times)) (if nil (looking-at "\\(?:.\\|\n\\)*?goto ") (let ((here (point))) (prog1 (re-search-forward "\\=\\(?:.\\|\n\\)*?goto" 100 t) (goto-char here)))) ))) ------=_Part_32590_6223315.1216304246920 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
On 7/17/08, Miles Bader <miles.bader@necel.com> wrote:
"Lennart Borgman" <lennart.borgman@gmail.com> writes:

>> > Yes, that is one possibility. But then perhaps I would assume that
>> > re-search-forward better might optimize that search since it can
>> > (in theory) cut off the searching at BOUND. In the case I am
>> > looking at performance is important.
>>
>> Why don't you time it?
>
> Because I thought someone here knew more about the performance differences
> (if any). I am also a bit surprised that looking-at does not have a BOUND
> parameter and hoped to get some comments on that.

Offhand it doesn't fit looking-at's interface particulary well -- while
you can come up with semantics for such a parameter, they're not
something obviously useful as is the case for searches.  Also, for
typical uses of looking-at, the performance difference isn't a factor.

Anyway, it seems a lot better to get actual data than
pontificate... premature optimization is the root of all evil,
after all... :-)
 
It looks like the performance is pretty equal. Here is my test code:
 

(benchmark-elapse
  (goto-char (point-min))
  (let ((times 10000))
    (while (> times 0)
      (setq times (1- times))

      (if nil
   (looking-at "\\(?:.\\|\n\\)*?goto")
 (let ((here (point)))
   (prog1
       (re-search-forward "\\=\\(?:.\\|\n\\)*?goto" 100 t)
     (goto-char here))))
      )))

------=_Part_32590_6223315.1216304246920--