[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Timing execution of function calls in Emacs lisp
From: |
Nikolaj Schumacher |
Subject: |
Re: Timing execution of function calls in Emacs lisp |
Date: |
Thu, 05 Jun 2008 20:27:46 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (darwin) |
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