From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: is there a emacs lisp timing command? Date: Mon, 23 Mar 2009 18:57:44 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3a58c551-a1da-4794-8eb3-7de3c504c556@n7g2000prc.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1237869413 15979 80.91.229.12 (24 Mar 2009 04:36:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Mar 2009 04:36:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 24 05:38:10 2009 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 1LlyOw-0007aN-BN for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Mar 2009 05:38:10 +0100 Original-Received: from localhost ([127.0.0.1]:40482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LlyNZ-0001R8-FB for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Mar 2009 00:36:45 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!n7g2000prc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 42 Original-NNTP-Posting-Host: 24.6.175.142 Original-X-Trace: posting.google.com 1237859864 28852 127.0.0.1 (24 Mar 2009 01:57:44 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 24 Mar 2009 01:57:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n7g2000prc.googlegroups.com; posting-host=24.6.175.142; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:167923 comp.emacs:98056 X-Mailman-Approved-At: Tue, 24 Mar 2009 00:35:33 -0400 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:63215 Archived-At: is there a elisp command like timing, that returns the time a function took? while testing some performance issues, i tried to write one. (defun xx-timing () "returns the timing." (interactive) (let (starttime endtime) (setq starttime (current-time)) ;; some function here (sleep-for 0 5) (setq endtime (current-time)) (message "%f" (+ (* (- (elt endtime 0) (elt starttime 0)) 65536) (- (elt endtime 1) (elt starttime 1)) (* (- (elt endtime 2) (elt starttime 2)) 0.001))) )) but after about 20 minutes on this, i gave up. It seems to me, when microseconds is involved (returned by current-time), the result is weired. I don't see any logical problem in my code, but the above code is obvious wrong, often returning results some 70 seconds extra whenever microseconds is involved. anyone has written a timing command somewhere? This is on: GNU Emacs 22.2.1 (powerpc-apple-darwin8.11.0, Carbon Version 1.6.0) of 2008-04-05 on g5.tokyo.stp.isas.jaxa.jp PowerPC G5, osx 10.4.11. Xah =E2=88=91 http://xahlee.org/ =E2=98=84