From: Nordlöw <per.nordlow@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Timing execution of function calls in Emacs lisp
Date: Thu, 5 Jun 2008 11:09:35 -0700 (PDT) [thread overview]
Message-ID: <ce8cc090-8844-4f18-8eb8-52d6599a8ed0@z72g2000hsb.googlegroups.com> (raw)
In-Reply-To: 86wsl3n92a.fsf@timbral.net
On 5 Juni, 18:25, Evans Winner <tho...@timbral.net> wrote:
> Nordlöw <per.nord...@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)))
benchmark-run() does the trick!
Many thanks,
Nordlöw
next prev parent reply other threads:[~2008-06-05 18:09 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 [this message]
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=ce8cc090-8844-4f18-8eb8-52d6599a8ed0@z72g2000hsb.googlegroups.com \
--to=per.nordlow@gmail.com \
--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.