From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Nordl=F6w?= Newsgroups: gmane.emacs.help Subject: Re: Timing execution of function calls in Emacs lisp Date: Thu, 5 Jun 2008 11:09:35 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <50d4f479-3c3e-4049-ba88-c989174118dc@j22g2000hsf.googlegroups.com> <86wsl3n92a.fsf@timbral.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1212691247 4571 80.91.229.12 (5 Jun 2008 18:40:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Jun 2008 18:40:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 05 20:41:21 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K4KOk-0007hn-St for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Jun 2008 20:41:19 +0200 Original-Received: from localhost ([127.0.0.1]:51385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K4KNy-0006rj-A7 for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Jun 2008 14:40:30 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!z72g2000hsb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 36 Original-NNTP-Posting-Host: 81.170.250.228 Original-X-Trace: posting.google.com 1212689375 3884 127.0.0.1 (5 Jun 2008 18:09:35 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 5 Jun 2008 18:09:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z72g2000hsb.googlegroups.com; posting-host=81.170.250.228; posting-account=ytJKAgoAAAA1tg4ScoRszebXiIldA5vg User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; sv-SE; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:159136 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:54485 Archived-At: On 5 Juni, 18:25, Evans Winner wrote: > Nordl=F6w writes: > > =A0 =A0 Is there a way to measure the execution time of function calls? > > =A0 =A0 Compare with following Matlab-snippet: > =A0 =A0 =A0 tic; do_something(with_some_arg); toc > > I am curious what the serious Elispers would do, so as bait > I wrote my own (almost certainly bad) attempt. =A0I understand > using `eval is bad form. =A0Still not too sure why. =A0Also, do > you need to do anything with the whatever it is your > function returns? =A0And I don't imagine this could be very > accurate. =A0Would something like this really have to be > implemented in C? =A0Maybe it already is. > > (defvar tic nil) > (defvar toc nil) > > (defun tic () > =A0 (setq tic (current-time))) > > (defun toc () > =A0 (setq toc (current-time))) > > (defun time (form) > =A0 (progn > =A0 =A0 (tic) > =A0 =A0 (eval form) > =A0 =A0 (toc) > =A0 =A0 (time-subtract toc tic))) benchmark-run() does the trick! Many thanks, Nordl=F6w