comparison lisp/prim/profile.el @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents 85ec50267440
children 169c0442b401
comparison
equal deleted inserted replaced
172:a38aed19690b 173:8eaf7971accc
58 (* 100 (/ (cdar info) sum))))) 58 (* 100 (/ (cdar info) sum)))))
59 (pop info))))) 59 (pop info)))))
60 60
61 ;;;###autoload 61 ;;;###autoload
62 (defmacro profile (&rest forms) 62 (defmacro profile (&rest forms)
63 "Turn on profiling, execute FORMS and stop profiling. 63 "Turn on profiling, execute FORMS and restore profiling state.
64 Profiling state here means that if profiling was not in effect when
65 PROFILE was called, it will be turned off after FORMS are evaluated.
66 Otherwise, profiling will be left running.
67
64 Returns the profiling info, printable by `pretty-print-profiling-info'." 68 Returns the profiling info, printable by `pretty-print-profiling-info'."
65 `(progn 69 `(progn
66 (unwind-protect 70 (if (profiling-active-p)
67 (progn 71 (progn
68 (start-profiling)
69 ,@forms) 72 ,@forms)
70 (stop-profiling)) 73 (unwind-protect
74 (progn
75 (start-profiling)
76 ,@forms)
77 (stop-profiling)))
71 (get-profiling-info))) 78 (get-profiling-info)))
72 79
73 (put 'profile 'lisp-indent-function 0) 80 (put 'profile 'lisp-indent-function 0)
74 81
75 ;;;###autoload 82 ;;;###autoload