profiler-start command has options for
cpu+mem. Is there a way to profile a command by elapsed time?
Related: emacs.stackexchange.com/q/539/50– MalabarbaOct 8, 2014 at 7:08
I'm not sure if you can do that using profiler.el as it is a sampling profiler. It's not actually measuring how long a function takes to run, it's periodically checking to see what function is currently being executed, and adding up all of those samples.
ELP or the EmacsLispProfiler is an instrumenting compiler. To enable instrumentation use M-x elp-instrument-function on one or more functions. After running code that calls the instrumented functions, run M-x elp-results. This will display a buffer showing the total number of calls and elapsed time for each instrumented function. Check out M-x find-libary elp for more information.
If you know exactly what function you want to profile, the benchmark library might also be useful.
You can use
determine how long a command takes.
(benchmark 100 (command))
100 is the number of repetitions, make it large enough for you results to be meaningful. And don’t forget you can also call it interactively.
(benchmark REPETITIONS FORM)
Print the time taken for REPETITIONS executions of FORM.
Interactively, REPETITIONS is taken from the prefix arg.
You can also use it for any arbitrary form, not just a single command.
(benchmark 100 (form to (be evaluated))