profiler-report 怎么修改function列的宽度啊

还有怎么把tree全部展开。

1 个赞

没现成的定制选项,不过可修改变量 profiler-report-cpu-line-formatprofiler-report-memory-line-format,默认是 50 和 55 个字符宽度。

文档 (elisp) Profiling 有提到 C-u RET

Use a prefix argument (C-u <RET>) to see the whole call tree below a function.

感谢大师指点!

记得这个问题我曾经回答过一次:lsp-ui启动速度问题 - #5,来自 twlz0ne

刚才顺便写了一个 resize 函数:

(defun dotemacs/profile-resize-report-view (&optional width)
  "Resize profile report view and set function column width to WIDTH.
If there is no WIDTH input, expand function column to fit `window-width'."
  (interactive)
  (unless (eq major-mode 'profiler-report-mode)
    (signal 'error (list "Not a Profiler Report buffer.")))
  (let* ((buffer (current-buffer))
         (type (if (string-prefix-p "*CPU-Profiler-Report " (buffer-name)) 'cpu 'memory))
         (format-sym (intern (format "profiler-report-%s-line-format" type)))
         (profiler-fun (intern (format "profiler-%s-profile" type))) 
         (width (or width
                    (read-number "Function column width: "
                                 (pcase (symbol-value format-sym)
                                   (`((,_ left) (,right right . ,_))
                                    (- (window-width) (line-number-display-width) right)))))))
    (eval `(let ((,format-sym
                  '((,width left) ,(cadr (symbol-value format-sym)))))
             (switch-to-buffer (profiler-report-setup-buffer (funcall ',profiler-fun)))))
    (kill-buffer buffer)))

M-x dotemacs/profile-resize-report-view 然后指定宽度,或者默认自适应窗口宽度。

1 个赞