From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#22114: 24.5; [PATCH] Allow profiler.el to display reports after stopping Date: Tue, 08 Dec 2015 18:22:47 +0200 Message-ID: <83bna0di5k.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1449591862 2217 80.91.229.3 (8 Dec 2015 16:24:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Dec 2015 16:24:22 +0000 (UTC) Cc: 22114@debbugs.gnu.org To: Vasilij Schneidermann Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 08 17:24:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a6L3i-0002wx-P7 for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Dec 2015 17:24:10 +0100 Original-Received: from localhost ([::1]:60587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6L3h-0003Nv-O6 for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Dec 2015 11:24:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6L3c-0003Nc-Uq for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:24:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6L3a-0004l8-9h for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:24:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6L3a-0004l1-6N for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1a6L3Z-0006sG-LZ for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:24:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Dec 2015 16:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 22114-submit@debbugs.gnu.org id=B22114.144959179626363 (code B ref 22114); Tue, 08 Dec 2015 16:24:01 +0000 Original-Received: (at 22114) by debbugs.gnu.org; 8 Dec 2015 16:23:16 +0000 Original-Received: from localhost ([127.0.0.1]:43402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a6L2p-0006r8-J5 for submit@debbugs.gnu.org; Tue, 08 Dec 2015 11:23:16 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:53087) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a6L2n-0006r0-5b for 22114@debbugs.gnu.org; Tue, 08 Dec 2015 11:23:13 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NZ100B00S1QY600@a-mtaout20.012.net.il> for 22114@debbugs.gnu.org; Tue, 08 Dec 2015 18:22:49 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NZ100BHYS61XJ10@a-mtaout20.012.net.il>; Tue, 08 Dec 2015 18:22:49 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109762 Archived-At: > Date: Tue, 8 Dec 2015 09:13:58 +0100 > From: Vasilij Schneidermann > > I've worked with a few other profilers than profiler.el so far and one > striking difference is that they allowed you to start a profiling run, > stop it and then retrieve the profiling log between these two points in > time. profiler.el on the other hand flatout refuses to display a report > after stopping which is especially puzzling given the `profiler-stop` > docstring: "Stop started profilers. Profiler logs will be kept." If > the logs are kept after all, why can't I take a look at them? > > I've attached a patch that solves this by caching the last accessable > profiler log. This allows both workflows to work, be it displaying a > report while the profiler is still running or displaying it after > stopping the profiler. Thanks. But I don't see why we would need to keep a copy of the profile around (and it looks weird to do that anyway, when we have a function that reports it). When profiler-cpu-log is called, it returns the profile before it resets it, so the data is available and should simply be used. I don't really understand why profiler.el insists on having the profiler running for providing the profile. The much simpler patch below makes it possible for me to invoke profiler-report whether a profile is running or not. Does it work for you? If not, can you tell what I missed? --- lisp/profiler.el~4 2015-11-11 07:57:32.000000000 +0200 +++ lisp/profiler.el 2015-12-08 17:54:27.380084700 +0200 @@ -216,19 +216,17 @@ (defun profiler-cpu-profile () "Return CPU profile." - (when (profiler-running-p 'cpu) - (profiler-make-profile - :type 'cpu - :timestamp (current-time) - :log (profiler-cpu-log)))) + (profiler-make-profile + :type 'cpu + :timestamp (current-time) + :log (profiler-cpu-log))) (defun profiler-memory-profile () "Return memory profile." - (when (profiler-memory-running-p) - (profiler-make-profile - :type 'memory - :timestamp (current-time) - :log (profiler-memory-log)))) + (profiler-make-profile + :type 'memory + :timestamp (current-time) + :log (profiler-memory-log))) ;;; Calltrees @@ -846,12 +844,12 @@ (defun profiler-report-cpu () (let ((profile (profiler-cpu-profile))) - (when profile + (when (and profile (profiler-profile-log profile)) (profiler-report-profile-other-window profile)))) (defun profiler-report-memory () (let ((profile (profiler-memory-profile))) - (when profile + (when (and profile (profiler-profile-log profile)) (profiler-report-profile-other-window profile)))) (defun profiler-report ()