The profiler-start command has options for cpu, mem, and cpu+mem. Is there a way to profile a command by elapsed time?


2 Answers 2


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 benchmark to 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.


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))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.