I posted this without any intention to maintain or extend it because I don't really use Emacs much, but @aspiers offered to turn it into a real repo people can contribute to, so check out the latest version there:
https://github.com/aspiers/etrace
- Either M-: (require 'etrace) or add (require 'etrace) to your Emacs config, or enable the micro-feature for it if you use micro-features from the non-Spacemacs Emacs config. (Optional) Run M-x customize-variable etrace-output-file to change where the trace will be written, it defaults to ~/etrace.json
- Run M-x elp-instrument-package and type in a function prefix to instrument all the functions with that prefix. It uses a completion box so note that by default it'll complete to whatever's selected in there, if you want to complete to a prefix with no corresponding function you can press the up arrow until the text you typed is selected rather than any completion. There's also M-x elp-instrument-function for individual functions.
- Run M-x etrace-clear
- Do the thing you want a trace of
- Run M-x etrace-write to write out the trace file.
- Go to chrome://tracing in Chrome and click the load button and open the trace file. Use alt+scroll to zoom. Alternatively use https://ui.perfetto.dev/#!/ which is also good but in different ways, for example it can show you the total time and percentage of time taken by different functions in a selection range.
- Make some changes and then repeat from step 4.
- Run M-x elp-restore-all to un-instrument any instrumented functions
Thanks, that's super helpful! Now I understand the point of
etrace--make-wrapper-advice
- very good to know. Also those two other renderer sites seem to perform a lot better than chrome://tracing, although I found that reducing the number of functions instrumented helps quite a lot, even though it only halves the size ofetrace.json
.Wrapping
(org-agenda)
in(unwind-protect ...)
didn't seem to make any difference, but I have noticed thatorg-agenda-skip
ends with the code(throw :skip t)
, so I wonder if this could explain it? If so, is there an easy way for the trace to correctly handle catching of exceptions? I'm pretty sure that this graph is incorrect in depicting that eachorg-agenda-skip
runs for a long time.