From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: In support of guile-emacs Date: Tue, 20 Oct 2015 09:53:32 +0000 Message-ID: <20151020095332.GA1781@acm.fritz.box> References: <20151019102414.GA2438@acm.fritz.box> <5624FADF.9070908@dancol.org> <20151019143527.GG2438@acm.fritz.box> <87eggqn6eo.fsf@T420.taylan> <20151019171909.GH2438@acm.fritz.box> <87wpuilml3.fsf@T420.taylan> <20151019201224.GJ2438@acm.fritz.box> <87h9lmlgim.fsf@T420.taylan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1445334751 15206 80.91.229.3 (20 Oct 2015 09:52:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 20 Oct 2015 09:52:31 +0000 (UTC) Cc: Xue Fuqiao , Christopher Allan Webber , Daniel Colascione , bruce.connor.am@gmail.com, emacs-devel To: Taylan Ulrich =?utf-8?B?QmF5xLFybMSxL0thbW1lcg==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 20 11:52:23 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZoTag-0006UW-Dk for ged-emacs-devel@m.gmane.org; Tue, 20 Oct 2015 11:52:22 +0200 Original-Received: from localhost ([::1]:44766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoTac-00011K-Tk for ged-emacs-devel@m.gmane.org; Tue, 20 Oct 2015 05:52:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoTaK-00010p-V8 for emacs-devel@gnu.org; Tue, 20 Oct 2015 05:52:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoTaG-00077q-HZ for emacs-devel@gnu.org; Tue, 20 Oct 2015 05:52:00 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:17083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoTaG-00077Q-7V for emacs-devel@gnu.org; Tue, 20 Oct 2015 05:51:56 -0400 Original-Received: (qmail 2695 invoked by uid 3782); 20 Oct 2015 09:51:54 -0000 Original-Received: from acm.muc.de (p548A5C6D.dip0.t-ipconnect.de [84.138.92.109]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 20 Oct 2015 11:51:52 +0200 Original-Received: (qmail 2824 invoked by uid 1000); 20 Oct 2015 09:53:33 -0000 Content-Disposition: inline In-Reply-To: <87h9lmlgim.fsf@T420.taylan> User-Agent: Mutt/1.5.23 (2014-03-12) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 193.149.48.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:192171 Archived-At: Hello, Taylan. On Mon, Oct 19, 2015 at 11:01:21PM +0200, Taylan Ulrich Bayırlı/Kammer wrote: > Alan Mackenzie writes: > > When I run this in Emacs on my 2.6 GHz Athlong machine, with M-: > > (time-it (let ((i 0)) (while (<= i 10000000) (setq i (1+ i))))) > > , this takes 1.8881s. (`time-it' is my own macro, not a standard Emacs > > one.) So, thus far, it's looking like Guile is a factor of ~700 faster. > > :-) > Oh oh, don't forget to byte-compile Elisp. Was my first mistake too. Hah! Yes, I had forgotten to byte-compile it. Creating a defun for it, then timing that I get 0.495s. > >> > ,optimize (let loop ((i 0)) (unless (= 10000000) (loop (+ i 1)))) > >> $2 = (if #f #f) > >> Oh, heh. A void 'do' loop doesn't get the same treatment because of > >> slightly different semantics, but a void named-let loop simply gets > >> eliminated out. > > Ah. Shame. How about calculating 1 + 2 + 3 + .... + 10,000,000 in a > > loop, then outputting it? The sum (50,000,005,000,000) should easily fit > > into a 64-bit Lisp integer. > > This: > > (time-it (let ((i 0) (s 0)) (while (<= i 10000000) (setq s (+ s i)) (setq i (1+ i))) (message "%s" s))) > > takes 3.389s on my machine. Again, byte-compiled, that takes 0.957s. > Takes about 0.62s here, when byte-compiled. Your machine is ~50% faster than mine. The Guile variant: > (let ((i 0) (s 0)) > (while (<= i 10000000) > (set! s (+ s i)) > (set! i (1+ i))) > (format #t "~s" s)) > Takes about 0.55s. That's a very literal transcription of the function > to Scheme. A more idiomatic version: > (let loop ((i 0) (s 0)) > (if (<= i 10000000) > (loop (+ i 1) (+ s i)) > (format #t "~s" s))) > Takes about 0.50s. So, we're talking about a speed up of around 13%/25% on a simple loop test, depending on whether or not an idiomatic Scheme formulation is used. Given that Guile compiled elisp wouldn't be optimised in this way, it would guess that the 13% is nearer the mark. But it would take a few real life tests to measure this better. > BTW here's a timing function that automatically byte-compiles the > argument (side-effectfully if a symbol): > (defun time (function) > "Return execution time of calling FUNCTION in seconds as a > float. FUNCTION is byte-compiled automatically." > (setq function (byte-compile function)) > (let ((start (current-time))) > (funcall function) > (let ((end (current-time))) > (let ((time (time-subtract end start))) > (+ (* (nth 0 time) (expt 2 16)) > (nth 1 time) > (/ (nth 2 time) 1000000.0)))))) Hint: there's a function `float-time' which does the job adequately, and is easier to manipulate. For comparison, here's my `time-it' macro (which doesn't itself do byte compilation): (defmacro time-it (&rest forms) "Time the running of a sequence of forms using `float-time'. Call like this: \"M-: (time-it (foo ...) (bar ...) ...)\"." `(let ((start (float-time))) ,@forms (- (float-time) start))) [ .... ] > > If Guile Emacs is advanced enough, timing the fontification of a file > > (say, ..../src/xdisp.c in our repository) would be a very meaningful > > timing. > I'm guessing that Guile Emacs isn't ready for that yet but, how can one > time that? Start by unfontifying the entire file, then scroll through it, fontifying a screen at a time. (sit-for 0) is used to ensure fontification at each stage. So something like this (untested) would do the job: (defun fully-fontify () (beginning-of-buffer) (font-lock-mode 0) (font-lock-mode 1) (condition-case nil (while t (sit-for 0) (scroll-up)))) The `condition-case' catches the error thrown when `scroll-up' reaches the end of the buffer. > Taylan -- Alan Mackenzie (Nuremberg, Germany).