[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

is there a emacs lisp timing command?

From: Xah Lee
Subject: is there a emacs lisp timing command?
Date: Mon, 23 Mar 2009 18:57:44 -0700 (PDT)
User-agent: G2/1.0

is there a elisp command like timing, that returns the time a function

while testing some performance issues, i tried to write one.

(defun xx-timing ()
  "returns the timing."
  (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

PowerPC G5, osx 10.4.11.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]