diff options
author | Tomohiro Matsuyama <tomo@cx4a.org> | 2012-08-22 18:15:17 +0900 |
---|---|---|
committer | Tomohiro Matsuyama <tomo@cx4a.org> | 2012-08-22 18:15:17 +0900 |
commit | ce56157e5f8ab1b244a63faf2e09ab8cd7c5ee23 (patch) | |
tree | 763342faddb3b8b7ac860d5f1b6b5f26ff2b01cc /lisp/profiler.el | |
parent | a4924b14919a427bf14913608b97d14a8c8e221f (diff) | |
download | emacs-ce56157e5f8ab1b244a63faf2e09ab8cd7c5ee23.tar.gz |
* profiler.el (with-sample-profiling): New macro.
(with-memory-profiling): New macro.
Diffstat (limited to 'lisp/profiler.el')
-rw-r--r-- | lisp/profiler.el | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/lisp/profiler.el b/lisp/profiler.el index db2d0eb461a..9e94f0d078c 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -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 |