diff options
| author | Tomohiro Matsuyama | 2012-08-22 18:15:17 +0900 |
|---|---|---|
| committer | Tomohiro Matsuyama | 2012-08-22 18:15:17 +0900 |
| commit | ce56157e5f8ab1b244a63faf2e09ab8cd7c5ee23 (patch) | |
| tree | 763342faddb3b8b7ac860d5f1b6b5f26ff2b01cc | |
| parent | a4924b14919a427bf14913608b97d14a8c8e221f (diff) | |
| download | emacs-ce56157e5f8ab1b244a63faf2e09ab8cd7c5ee23.tar.gz emacs-ce56157e5f8ab1b244a63faf2e09ab8cd7c5ee23.zip | |
* profiler.el (with-sample-profiling): New macro.
(with-memory-profiling): New macro.
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/profiler.el | 36 |
2 files changed, 35 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 366380b4ec4..d8134f2c046 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | * profiler.el: Switch to cl-lib. | 3 | * profiler.el: Switch to cl-lib. |
| 4 | (profiler-start): Change mode spec. | 4 | (profiler-start): Change mode spec. |
| 5 | (with-sample-profiling): New macro. | ||
| 6 | (with-memory-profiling): New macro. | ||
| 5 | 7 | ||
| 6 | 2012-08-22 Daiki Ueno <ueno@unixuser.org> | 8 | 2012-08-22 Daiki Ueno <ueno@unixuser.org> |
| 7 | 9 | ||
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." | |||
| 575 | (memory-profiler-reset) | 575 | (memory-profiler-reset) |
| 576 | t) | 576 | t) |
| 577 | 577 | ||
| 578 | (defun profiler-report () | 578 | (defun sample-profiler-report () |
| 579 | (interactive) | ||
| 580 | (let ((sample-log (sample-profiler-log))) | 579 | (let ((sample-log (sample-profiler-log))) |
| 581 | (when sample-log | 580 | (when sample-log |
| 582 | (profiler-log-fixup sample-log) | 581 | (profiler-log-fixup sample-log) |
| 583 | (profiler-report-log sample-log))) | 582 | (profiler-report-log sample-log)))) |
| 583 | |||
| 584 | (defun memory-profiler-report () | ||
| 584 | (let ((memory-log (memory-profiler-log))) | 585 | (let ((memory-log (memory-profiler-log))) |
| 585 | (when memory-log | 586 | (when memory-log |
| 586 | (profiler-log-fixup memory-log) | 587 | (profiler-log-fixup memory-log) |
| 587 | (profiler-report-log memory-log)))) | 588 | (profiler-report-log memory-log)))) |
| 588 | 589 | ||
| 590 | (defun profiler-report () | ||
| 591 | (interactive) | ||
| 592 | (sample-profiler-report) | ||
| 593 | (memory-profiler-report)) | ||
| 594 | |||
| 589 | ;;;###autoload | 595 | ;;;###autoload |
| 590 | (defun profiler-find-log (filename) | 596 | (defun profiler-find-log (filename) |
| 591 | (interactive | 597 | (interactive |
| @@ -596,5 +602,29 @@ otherwise collapse the entry." | |||
| 596 | (let ((log (read (current-buffer)))) | 602 | (let ((log (read (current-buffer)))) |
| 597 | (profiler-report-log log)))) | 603 | (profiler-report-log log)))) |
| 598 | 604 | ||
| 605 | |||
| 606 | |||
| 607 | ;;; Profiling helpers | ||
| 608 | |||
| 609 | (cl-defmacro with-sample-profiling ((&key (interval profiler-sample-interval)) &rest body) | ||
| 610 | `(progn | ||
| 611 | (sample-profiler-start ,interval) | ||
| 612 | (sample-profiler-reset) | ||
| 613 | (unwind-protect | ||
| 614 | (progn ,@body) | ||
| 615 | (sample-profiler-stop) | ||
| 616 | (sample-profiler-report) | ||
| 617 | (sample-profiler-reset)))) | ||
| 618 | |||
| 619 | (cl-defmacro with-memory-profiling (() &rest body) | ||
| 620 | `(progn | ||
| 621 | (memory-profiler-start) | ||
| 622 | (memory-profiler-reset) | ||
| 623 | (unwind-protect | ||
| 624 | (progn ,@body) | ||
| 625 | (memory-profiler-stop) | ||
| 626 | (memory-profiler-report) | ||
| 627 | (memory-profiler-reset)))) | ||
| 628 | |||
| 599 | (provide 'profiler) | 629 | (provide 'profiler) |
| 600 | ;;; profiler.el ends here | 630 | ;;; profiler.el ends here |