From: Nikolaj Schumacher <n_schumacher@web.de>
To: Nordlöw <per.nordlow@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Timing execution of function calls in Emacs lisp
Date: Thu, 05 Jun 2008 20:27:46 +0200 [thread overview]
Message-ID: <m2abhzybx9.fsf@nschum.de> (raw)
In-Reply-To: <50d4f479-3c3e-4049-ba88-c989174118dc@j22g2000hsf.googlegroups.com> ("Nordlöw"'s message of "Thu\, 5 Jun 2008 06\:24\:45 -0700 \(PDT\)")
Nordlöw <per.nordlow@gmail.com> wrote:
> Is there a way to measure the execution time of function calls?
>
> Compare with following Matlab-snippet:
> tic; do_something(with_some_arg); toc
>
> In emacs lisp perhaps something like:
> (time FUNCTION ARGS...)
Here's what I use. It works well enough for my purposes.
(defmacro measure-time (&rest body)
"Measure the time it takes to evaluate BODY."
`(let ((time (current-time)))
,@body
(message "%.06f" (float-time (time-since time)))))
It's used like this:
(measure-time
(dotimes (i 100000)
(1+ 1)))
regards,
Nikolaj Schumacher
prev parent reply other threads:[~2008-06-05 18:27 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
2008-06-05 18:09 ` Nordlöw
2008-06-05 18:27 ` Nikolaj Schumacher [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2abhzybx9.fsf@nschum.de \
--to=n_schumacher@web.de \
--cc=help-gnu-emacs@gnu.org \
--cc=per.nordlow@gmail.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).