Commit ce56157e authored by Tomohiro Matsuyama's avatar Tomohiro Matsuyama
Browse files

* profiler.el (with-sample-profiling): New macro.

(with-memory-profiling): New macro.
parent a4924b14
......@@ -2,6 +2,8 @@
 
* profiler.el: Switch to cl-lib.
(profiler-start): Change mode spec.
(with-sample-profiling): New macro.
(with-memory-profiling): New macro.
 
2012-08-22 Daiki Ueno <ueno@unixuser.org>
 
......
......@@ -575,17 +575,23 @@ otherwise collapse the entry."
(memory-profiler-reset)
t)
(defun profiler-report ()
(interactive)
(defun sample-profiler-report ()
(let ((sample-log (sample-profiler-log)))
(when sample-log
(profiler-log-fixup sample-log)
(profiler-report-log sample-log)))
(profiler-report-log sample-log))))
(defun memory-profiler-report ()
(let ((memory-log (memory-profiler-log)))
(when memory-log
(profiler-log-fixup memory-log)
(profiler-report-log memory-log))))
(defun profiler-report ()
(interactive)
(sample-profiler-report)
(memory-profiler-report))
;;;###autoload
(defun profiler-find-log (filename)
(interactive
......@@ -596,5 +602,29 @@ otherwise collapse the entry."
(let ((log (read (current-buffer))))
(profiler-report-log log))))
;;; Profiling helpers
(cl-defmacro with-sample-profiling ((&key (interval profiler-sample-interval)) &rest body)
`(progn
(sample-profiler-start ,interval)
(sample-profiler-reset)
(unwind-protect
(progn ,@body)
(sample-profiler-stop)
(sample-profiler-report)
(sample-profiler-reset))))
(cl-defmacro with-memory-profiling (() &rest body)
`(progn
(memory-profiler-start)
(memory-profiler-reset)
(unwind-protect
(progn ,@body)
(memory-profiler-stop)
(memory-profiler-report)
(memory-profiler-reset))))
(provide 'profiler)
;;; profiler.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment