From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tianxiang Xiong Newsgroups: gmane.emacs.devel Subject: Re: Performance issue w/ `cl-loop`s `collect...into` Date: Mon, 9 Apr 2018 08:28:48 -0700 Message-ID: References: <41631665-6cd6-7096-8866-5ab9559a14ef@gmail.com> <1d5b85f5-62cd-f2f3-0b71-9e2a2cf2ef9e@gmail.com> <87r2nobmcq.fsf@tcd.ie> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="089e08249144f9618d05696c0fdb" X-Trace: blaine.gmane.org 1523287689 10185 195.159.176.226 (9 Apr 2018 15:28:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 9 Apr 2018 15:28:09 +0000 (UTC) Cc: Stefan Monnier , Emacs developers To: "Basil L. Contovounesios" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 09 17:28:05 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f5YiC-0002Z7-6D for ged-emacs-devel@m.gmane.org; Mon, 09 Apr 2018 17:28:04 +0200 Original-Received: from localhost ([::1]:46769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5YkH-00010y-OI for ged-emacs-devel@m.gmane.org; Mon, 09 Apr 2018 11:30:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5Yix-0008SW-6Z for emacs-devel@gnu.org; Mon, 09 Apr 2018 11:28:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5Yiw-00060C-7s for emacs-devel@gnu.org; Mon, 09 Apr 2018 11:28:51 -0400 Original-Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:38924) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f5Yiw-0005zR-15 for emacs-devel@gnu.org; Mon, 09 Apr 2018 11:28:50 -0400 Original-Received: by mail-wm0-x22d.google.com with SMTP id f125so17547673wme.4 for ; Mon, 09 Apr 2018 08:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+IUg8GF7po8/NYx1oKSnh8x54IG0Txu2DG8nJUVXepI=; b=iCIacLh1Zdwy3K8Smex1Enz0YpEX70poVKFZ/d5jMWvQN9qV+SjyE/s0AaAixkUvB9 /eq5sDXRgBi1vrjyffIayt2nhcdgF67pFQ+TQT40wdWKRYyYYdpmUkVdsqBwmxrjjrx9 4MvRVwItNDukf5ZVyuotCylhNELyG0m0Pp6CieIXsQNW2kafwr90UoUUdtuERST+zQbk tNxSHRgxVl/CS8kl/f9QIH/vjS2Z1nH0dWE0Z3NyWUQfugEgF1GYnfvI2Ue6ytKXhnP7 PItQkuwsKPwjUWwQTv77d8NTdyYXOXc1Uu5Qp358VTXsot/BfmyJy8rXydAcXgr9w4OV nimA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+IUg8GF7po8/NYx1oKSnh8x54IG0Txu2DG8nJUVXepI=; b=IlKdXQYrM0uDN0v6CQ3yqAcYrZcGqHFSEWyXwWee56IQJ3dPlvBWLiyRD9m6IrYjCs lbATG4yBS7duRbgQY4Ov1GRndfUTMYxWcf8wVbKbLpBmASvm9LVChVoauGLRk0n+9fyY czNsuaxUbOBWsvrxt53JqzSp8MOErZPOHYNcbpFyGycDHT44Mh0BWKtGQDPjmk/4GV4S IOc7AgV4pCuXQCar7YE2hixq6oIF8Pzlwyp4PR7Tnt4w2VkjuOvz9aPs+1uOK32wiP8U X5n1/Z3UA8/kYtELFrfRhEB+f+iLcywNEmfjMcNIWQyTmv3+okgD8yymKfmeiobx3AcB l02A== X-Gm-Message-State: ALQs6tB9TpT+VWC0yO3MV659KkDA/2PPiQXA2MDXJ/J8xe2HF9Adqzws iqo8UGx92oLMyizqR94UwAGLtm3S9CskhAwni1w= X-Google-Smtp-Source: AIpwx4/NugAFSwxVRlIxrSVzrKJ16B6VEh+sSnTGfjIav4b4tW+gAXYEZu2B0U6JOC4A4URTY9G5rc5gTSY/NN9wdOM= X-Received: by 10.80.244.17 with SMTP id r17mr22795462edm.155.1523287728938; Mon, 09 Apr 2018 08:28:48 -0700 (PDT) Original-Received: by 10.80.203.195 with HTTP; Mon, 9 Apr 2018 08:28:48 -0700 (PDT) In-Reply-To: <87r2nobmcq.fsf@tcd.ie> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:224467 Archived-At: --089e08249144f9618d05696c0fdb Content-Type: text/plain; charset="UTF-8" Here's the result of `benchmark-run` on the new code: (benchmark-run 10 (cl-loop for i in (number-sequence 1 1E6) collect i)) ;; => (10.488984668 6 3.555157208999999) and old code: (benchmark-run 10 (cl-loop for i in (number-sequence 1 1E6) collect i)) ;; => (14.876455789000001 25 2.328459104999999) So there actually seems to be an improvement due to less GC. On Mon, Apr 9, 2018 at 5:22 AM, Basil L. Contovounesios wrote: > Tianxiang Xiong writes: > > > Is there a function to easily time operations in Emacs Lisp? Something > > like Clojure's `core/time`? > > There are the macros benchmark-run and benchmark-run-compiled, as > mentioned under (info "(elisp) Profiling"). > > -- > Basil > --089e08249144f9618d05696c0fdb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Here's the result of `benchmark-run` on the new code:<= div>
(benchmark-run 10 (cl-loop for i in (number-sequenc= e 1 1E6)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0collect i))

;; =3D> (10.488= 984668 6 3.555157208999999)

and old code:

(benchmark-run 10 (cl-loop for i in (number-seq= uence 1 1E6)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0collect i))

;; =3D> (14= .876455789000001 25 2.328459104999999)

So th= ere actually seems to be an improvement due to less GC.

On Mon, Apr 9, 2018 at 5:22 AM,= Basil L. Contovounesios <contovob@tcd.ie> wrote:
Tianxiang X= iong <tianxiang.xiong@gmail= .com> writes:

> Is there a function to easily time operations in Emacs Lisp? Something=
> like Clojure's `core/time`?

There are the macros benchmark-run and benchmark-run-compiled, as mentioned under (info "(elisp) Profiling").

--
Basil

--089e08249144f9618d05696c0fdb--