all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Evans Winner <thorne@timbral.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Timing execution of function calls in Emacs lisp
Date: Thu, 05 Jun 2008 10:25:01 -0600	[thread overview]
Message-ID: <86wsl3n92a.fsf@timbral.net> (raw)
In-Reply-To: 50d4f479-3c3e-4049-ba88-c989174118dc@j22g2000hsf.googlegroups.com

Nordlöw <per.nordlow@gmail.com> writes:

    Is there a way to measure the execution time of function calls?
 
    Compare with following Matlab-snippet:
      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.  I understand
using `eval is bad form.  Still not too sure why.  Also, do
you need to do anything with the whatever it is your
function returns?  And I don't imagine this could be very
accurate.  Would something like this really have to be
implemented in C?  Maybe it already is.

(defvar tic nil)
(defvar toc nil)

(defun tic ()
  (setq tic (current-time)))

(defun toc ()
  (setq toc (current-time)))

(defun time (form)
  (progn
    (tic)
    (eval form)
    (toc)
    (time-subtract toc tic)))


  parent reply	other threads:[~2008-06-05 16:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-05 13:24 Timing execution of function calls in Emacs lisp Nordlöw
2008-06-05 15:27 ` Lennart Borgman (gmail)
2008-06-05 16:25 ` Evans Winner [this message]
2008-06-05 18:09   ` Nordlöw
2008-06-05 18:27 ` Nikolaj Schumacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86wsl3n92a.fsf@timbral.net \
    --to=thorne@timbral.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.