From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: thierry.volpiatto@gmail.com Newsgroups: gmane.emacs.help Subject: Re: is there a emacs lisp timing command? Date: Tue, 24 Mar 2009 07:46:19 +0100 Message-ID: <87wsafpgec.fsf@tux.homenetwork> References: <3a58c551-a1da-4794-8eb3-7de3c504c556@n7g2000prc.googlegroups.com> <8763hzqwiu.fsf@tux.homenetwork> <871vsnqvge.fsf@tux.homenetwork> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1237877627 31077 80.91.229.12 (24 Mar 2009 06:53:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Mar 2009 06:53: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 Tue Mar 24 07:55:04 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 1Lm0XO-0007sB-Qc for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Mar 2009 07:55:03 +0100 Original-Received: from localhost ([127.0.0.1]:47802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lm0W2-0007r5-1g for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Mar 2009 02:53:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lm0Vi-0007qq-11 for help-gnu-emacs@gnu.org; Tue, 24 Mar 2009 02:53:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lm0Vd-0007qU-Gh for help-gnu-emacs@gnu.org; Tue, 24 Mar 2009 02:53:17 -0400 Original-Received: from [199.232.76.173] (port=39229 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lm0Vd-0007qR-CH for help-gnu-emacs@gnu.org; Tue, 24 Mar 2009 02:53:13 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:28580) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lm0Vc-0005OY-PC for help-gnu-emacs@gnu.org; Tue, 24 Mar 2009 02:53:13 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lm0Vc-0006dz-0I for help-gnu-emacs@gnu.org; Tue, 24 Mar 2009 02:53:12 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Lm0Vb-0001mg-Am for help-gnu-emacs@gnu.org; Tue, 24 Mar 2009 06:53:11 +0000 Original-Received: from 253.211.85-79.rev.gaoland.net ([79.85.211.253]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 24 Mar 2009 06:53:11 +0000 Original-Received: from thierry.volpiatto by 253.211.85-79.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 24 Mar 2009 06:53:11 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 90 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 253.211.85-79.rev.gaoland.net Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEUHAwNfJRBVTESlTym0 RB/OwKFivhZqAAAACXBIWXMAAAsSAAALEgHS3X78AAAACXZwQWcAAAAwAAAAMADO7oxXAAABeElE QVQ4y3VTW47CMAyMwwUyTfYfUvG/wfC/ET4B0t7/KmsHurRgXFVVPRm/xglhsRj2+npW98G3+Amp tS5BXxl3SqzcXGRuEyf7n5lPA9jXetNPRhE7EJkzfz8YWnIgBSwW95TK4H79/t4GINKNADWj4PgA DiJX/ZxFDzDXeb4oYMw7kNUvyMzcaj3ioICG4hCKEShkPpwQ49Q05nnkGAQLDFDdExjm0qpowBYA Wi61bDlFU1GW0WbY2dSJYX5ZD2S0AiZL+rPyE19TpMzP2IvNWly+NkuWNgD4pO2oL73IQXoSyVX2 NHna7tgadWRXoCdvf2guqEcvGHqZwE520iRD0/QCYiiTE+U21w1Qxvg6iSp9fbIiDCnSAelDkCVF Vn+HekqXzRybwJ40xF4DMRG6SWGK9G1lYzHSxLYEm05GWbpJCB6A9tb9A3BGn2XdwJbS/WuInj74 4QNF8sVFdP3vl+5tgYp4Ev7fyrfFMkXgElDgV4uV/w8TWEeLCIGJ/AAAACV0RVh0Y3JlYXRlLWRh dGUAMjAwOC0wNS0zMVQyMDoxNDoyMiswMDowMAS7YjIAAAARdEVYdGpwZWc6Y29sb3JzcGFjZQAy LHVVnwAAACB0RVh0anBlZzpzYW1wbGluZy1mYWN0b3IAMngyLDF4MSwxeDFJ+qa0AAAAJXRFWHRt b2RpZnktZGF0ZQAyMDA3LTEwLTI4VDE2OjA4OjQ4KzAwOjAw44nspgAAAABJRU5ErkJggg== User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.91 (gnu/linux) Cancel-Lock: sha1:EaCqBgg9euuTqk+S32sjrIvvF8I= X-detected-kernel: by mx20.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:63221 Archived-At: hoops! i didn't remember i had this one also: (defmacro chrono-func (output fn &rest args) `(let ((init-time (cadr (current-time))) (final-time) (final-result)) (setq final-result (funcall ,fn ,@args)) (setq final-time (- (cadr (current-time)) init-time)) (message "Time:%2s s" final-time) (when ,output final-result))) May be it's exactly what you want. thierry.volpiatto@gmail.com writes: > And this can help also:(adapt for your case with traverselisp code). > > > (defun current-human-time () > (let* ((cur-time (decode-time (current-time))) > (h (int-to-string (nth 2 cur-time))) > (m (int-to-string (nth 1 cur-time))) > (s (int-to-string (nth 0 cur-time)))) > (message "%s" (concat h ":" m ":" s)))) > > (defvar my-time nil) > (defun start-watch () > (setq my-time (run-with-timer 1 1 'current-human-time))) > > (defun stop-watch () > (cancel-timer my-time) > (setq my-time nil)) > > thierry.volpiatto@gmail.com writes: > >> Hi, >> have a look at traverselisp.el, >> the function `traverse-deep-rfind' have a timer. >> http://www.emacswiki.org/cgi-bin/emacs/traverselisp.el >> >> Xah Lee writes: >> >>> 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 >>> ∑ http://xahlee.org/ >>> >>> ☄ >>> >>> -- A + Thierry Volpiatto Location: Saint-Cyr-Sur-Mer - France