Is there a way to profile or time code that simulates interactive editing?
The gist of what I want to do is that I have some code that runs during font-lock, and sometimes it makes editing sluggish. What I would like is a way to run a test that simulates the editing (and corresponding font-lock operations) and does some timing so I can test which implementations are fastest.
Supposing I have a
measure-time macro (eg from https://stackoverflow.com/questions/23622296/emacs-timing-execution-of-function-calls-in-emacs-lisp), this test code would look like this, where example/info.org is the file I want to test on.
(cl-loop for i to 3 collect (with-temp-buffer (insert-file-contents "example/info.org") (org-mode) ;; Goto place in file where I know editing becomes slow (re-search-forward "ref:") (end-of-line) (measure-time (dotimes (i 5) ;; this code should act like if typed a character, triggering a ;; font-lock update (insert " ")))))
and it would return a list of execution times for the edit operation (in this case inserting characters).
Then, I could try different implementations of the code to see which one makes for the fastest editing.
Are there any standard tools for doing this?