summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2020-12-22 12:06:21 +0000
committerAlan Mackenzie <acm@muc.de>2020-12-22 12:06:21 +0000
commit9920929e7b538f8bf8fb1dd7a9ae7cd1fe5d2b31 (patch)
tree49900fc5aff77800d994796df7c3f4b4e6401fdc
parent188b09d6d9b12a2ec7f8ed4ad4c0bd55acbb37b1 (diff)
downloademacs-9920929e7b538f8bf8fb1dd7a9ae7cd1fe5d2b31.tar.gz
emacs-9920929e7b538f8bf8fb1dd7a9ae7cd1fe5d2b31.tar.bz2
emacs-9920929e7b538f8bf8fb1dd7a9ae7cd1fe5d2b31.zip
Re-order the items in `profiler-report' output.
Putting the usage figures first on the line will eliminate the truncation of function names. lisp/profiler.el (profiler-version): Change to "28.1". (profiler-format): Enhance, so that a width of zero means print the string without padding or truncation. (profiler-report-cpu-line-format, profiler-report-memory-line-format): Amend for the new layout. The number of places for the cpu samples has been reduced from 19 to 12 (enough for ~30 years at 1,000 samples per second). (profiler-report-line-format, profiler-report-describe-entry): Amend for the new order of arguments to profiler-format. etc/NEWS (Specialized Modes): Add an entry documenting this change. doc/lispref/debugging.texi (Profiling): Describe the new ordering of the items in place of the old ordering.
-rw-r--r--doc/lispref/debugging.texi13
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/profiler.el28
3 files changed, 32 insertions, 17 deletions
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 3fea604184c..661961f9379 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -1009,13 +1009,14 @@ profiling, so we don't recommend leaving it active except when you are
actually running the code you want to examine).
The profiler report buffer shows, on each line, a function that was
-called, followed by how much resources (cpu or memory) it used in
+called, preceded by how much resources (cpu or memory) it used in
absolute and percentage terms since profiling started. If a given
-line has a @samp{+} symbol at the left-hand side, you can expand that
-line by typing @kbd{@key{RET}}, in order to see the function(s) called
-by the higher-level function. Use a prefix argument (@kbd{C-u
-@key{RET}}) to see the whole call tree below a function. Pressing
-@kbd{@key{RET}} again will collapse back to the original state.
+line has a @samp{+} symbol to the left of the function name, you can
+expand that line by typing @kbd{@key{RET}}, in order to see the
+function(s) called by the higher-level function. Use a prefix
+argument (@kbd{C-u @key{RET}}) to see the whole call tree below a
+function. Pressing @kbd{@key{RET}} again will collapse back to the
+original state.
Press @kbd{j} or @kbd{mouse-2} to jump to the definition of a function
at point. Press @kbd{d} to view a function's documentation. You can
diff --git a/etc/NEWS b/etc/NEWS
index 46b8435a14d..92493b70a0c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -303,6 +303,14 @@ the buffer cycles the whole buffer between "only top-level headings",
* Changes in Specialized Modes and Packages in Emacs 28.1
++++
+** profiler.el
+The results displayed by 'profiler-report' now have the usage figures
+at the left hand side followed by the function name. This is intended
+to make better use of the horizontal space, in particular eliminating
+the truncation of function names. There is no way to get the former
+layout back.
+
** Loading dunnet.el in batch mode doesn't start the game any more.
Instead you need to do "emacs -f dun-batch" to start the game in
batch mode.
diff --git a/lisp/profiler.el b/lisp/profiler.el
index bf8aacccc37..13ac040f565 100644
--- a/lisp/profiler.el
+++ b/lisp/profiler.el
@@ -34,7 +34,7 @@
:version "24.3"
:prefix "profiler-")
-(defconst profiler-version "24.3")
+(defconst profiler-version "28.1")
(defcustom profiler-sampling-interval 1000000
"Default sampling interval in nanoseconds."
@@ -85,6 +85,9 @@
(t
(profiler-ensure-string arg)))
for len = (length str)
+ if (zerop width)
+ collect str into frags
+ else
if (< width len)
collect (progn (put-text-property (max 0 (- width 2)) len
'invisible 'profiler str)
@@ -445,14 +448,16 @@ Optional argument MODE means only check for the specified mode (cpu or mem)."
:group 'profiler)
(defvar profiler-report-cpu-line-format
- '((50 left)
- (24 right ((19 right)
- (5 right)))))
+ '((14 right ((9 right)
+ (5 right)))
+ (1 left "%s")
+ (0 left)))
(defvar profiler-report-memory-line-format
- '((55 left)
- (19 right ((14 right profiler-format-number)
- (5 right)))))
+ '((20 right ((15 right profiler-format-number)
+ (5 right)))
+ (1 left "%s")
+ (0 left)))
(defvar-local profiler-report-profile nil
"The current profile.")
@@ -505,13 +510,14 @@ RET: expand or collapse"))
(profiler-format (cl-ecase (profiler-profile-type profiler-report-profile)
(cpu profiler-report-cpu-line-format)
(memory profiler-report-memory-line-format))
- name-part
(if diff-p
(list (if (> count 0)
(format "+%s" count)
count)
"")
- (list count count-percent)))))
+ (list count count-percent))
+ " "
+ name-part)))
(defun profiler-report-insert-calltree (tree)
(let ((line (profiler-report-line-format tree)))
@@ -735,11 +741,11 @@ below entry at point."
(cpu
(profiler-report-header-line-format
profiler-report-cpu-line-format
- "Function" (list "CPU samples" "%")))
+ (list "Samples" "%") " " "Function"))
(memory
(profiler-report-header-line-format
profiler-report-memory-line-format
- "Function" (list "Bytes" "%")))))
+ (list "Bytes" "%") " " "Function"))))
(let ((predicate (cl-ecase order
(ascending #'profiler-calltree-count<)
(descending #'profiler-calltree-count>))))