From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Carter Newsgroups: gmane.lisp.guile.user Subject: Re: Is this a good use for "compile" Date: Tue, 20 Feb 2018 09:28:07 +0000 Message-ID: <1be8aa32-69f9-afec-321b-8b5b1d041c76@gmail.com> References: <5d3802ce-88b8-7b8a-13e5-b1fbd9dfd0c9@sapo.pt> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1519120571 10604 195.159.176.226 (20 Feb 2018 09:56:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 20 Feb 2018 09:56:11 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Feb 20 10:56:07 2018 Return-path: Envelope-to: guile-user@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 1eo4By-0001Q7-Rp for guile-user@m.gmane.org; Tue, 20 Feb 2018 10:26:30 +0100 Original-Received: from localhost ([::1]:54302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eo4Dz-0000sf-D1 for guile-user@m.gmane.org; Tue, 20 Feb 2018 04:28:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eo4De-0000sP-W7 for guile-user@gnu.org; Tue, 20 Feb 2018 04:28:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eo4Db-0002Vq-NE for guile-user@gnu.org; Tue, 20 Feb 2018 04:28:14 -0500 Original-Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:44677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eo4Db-0002VH-FO for guile-user@gnu.org; Tue, 20 Feb 2018 04:28:11 -0500 Original-Received: by mail-wr0-x235.google.com with SMTP id v65so12268399wrc.11 for ; Tue, 20 Feb 2018 01:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=6M0SZJOJHac+0vMdBQcSEtE9VeFbekxHhKqPmEFvB3w=; b=ZaTtFJ1rqyspALrg/b0JFbBy+hLxqV1Se9eMV1FGHJvglGFLUMU0JhoDxhSb5eRbMH CskicirzEN+23dY9rWFpPmCgh0gFBkAhKhI5EMbErWYoAUY6VkwBjJkEWXcMFrT48v4e xh5ytQa7netDCJT3mwAkSYFqzD55LlIoQcnpwWHbsaVd7Xy7dk5m47J0r8RMglEDm1fI f4KAP923+x/L5mQmsYe1PJOZcByjzrCAwZKoHKcBdFsdm5jFHTO0kcIPJJ58GE6BRuJ+ VOZFrAONHRqNIyaDFEFWlPaU/PyU41L7WYprAfHfyFMRMWtbgCzYKhWC2ZvE15TTNWS5 rkcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6M0SZJOJHac+0vMdBQcSEtE9VeFbekxHhKqPmEFvB3w=; b=g8NxPlLQcjgHBn/0VYyhqVhAd0cAaS0nV63VncwCO+8VNJ/fLpkl/2g4gKj//3b3ck eW7H52pdvf4t0n0/mjPAlR96ghEnZNF6xlMtozH9vuu52qbRlgFBNFDit+Q6mY0ETxVm jh4DrQaMw0hH7cOLWaNHEwnOG+zXXJ4nhf25OFfVi6qvigRKP6bo5+oq5wUN0HlNSpmx rXCvnnquM76j9wQ3dqkaCJeDDIby/P8H8ZPphM4JfAurlmFDK9GDohwTtNsOEAQXw/pi 7TjVe49qAwuBU7fX2BXqe3pFYahQj0AqorIgq8u5+VrBR+teaeUz1Oc8Yh95TmwpXARe TkVQ== X-Gm-Message-State: APf1xPDRziU1n3jW40hlEDL9Feo37FbpIxrh6ikfukZMb8lX8OI8SnlQ JSNlx1ecGzJizGn7oyfpy0TuLg== X-Google-Smtp-Source: AH8x227icnCFOAxL1UZ0eYZHDiyCviQT1o1w/77kYYaANsN26yJq5QzT33XmoBPDOihIVXPj0oF44g== X-Received: by 10.223.128.104 with SMTP id 95mr16605584wrk.139.1519118889682; Tue, 20 Feb 2018 01:28:09 -0800 (PST) Original-Received: from [192.168.0.13] ([217.155.40.178]) by smtp.gmail.com with ESMTPSA id h90sm17470917wrh.44.2018.02.20.01.28.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 01:28:08 -0800 (PST) In-Reply-To: <5d3802ce-88b8-7b8a-13e5-b1fbd9dfd0c9@sapo.pt> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::235 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14453 Archived-At: On 20/02/18 00:08, Vítor De Araújo wrote: > > We can try this out: > > scheme@(guile-user)> (use-modules (system base compile)) > scheme@(guile-user)> (define exp '(lambda (n) >                                     (let loop ([i n] [total 0]) >                                       (if (= i 0) >                                           total >                                         (loop (1- i) (+ i total)))))) > scheme@(guile-user)> (define f1 (eval exp (interaction-environment))) > scheme@(guile-user)> (define f2 (compile exp #:env > (interaction-environment))) > scheme@(guile-user)> ,time (f1 1000000) > $2 = 500000500000 > ;; 0.845240s real time, 0.895351s run time.  0.071494s spent in GC. > scheme@(guile-user)> ,time (f2 1000000) > $3 = 500000500000 > ;; 0.067317s real time, 0.067278s run time.  0.000000s spent in GC. > > So the answer does seem to be "yes": the compiled procedure is much > faster. > Thanks. A 10X speedup is just what the doctor ordered. As it happened, I was looking for a way to time functions, and didn't realise that guile has a convenient way of doing this.